From 9ff8a8998ceeb12ca28b5e385e6867b0b1bda328 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Tue, 2 Apr 2024 14:12:58 +0300 Subject: [PATCH 01/23] Fix Carousel undefined array item warnings. (#36681) * Added an isset check to avoid non-existing array key warnings. * CHangelog. --- .../jetpack/changelog/fix-carousel-undefined-array-item | 4 ++++ .../plugins/jetpack/modules/carousel/jetpack-carousel.php | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/fix-carousel-undefined-array-item diff --git a/projects/plugins/jetpack/changelog/fix-carousel-undefined-array-item b/projects/plugins/jetpack/changelog/fix-carousel-undefined-array-item new file mode 100644 index 0000000000000..be163ecb74d0a --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-carousel-undefined-array-item @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Carousel: Add extra isset check to avoid warnings. diff --git a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php index e085f661c0ff7..b1eaab2bc2286 100644 --- a/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php +++ b/projects/plugins/jetpack/modules/carousel/jetpack-carousel.php @@ -882,7 +882,11 @@ class_exists( 'Jetpack_AMP_Support' ) * This is meant as a relatively quick fix, as a better fix is likely to update the get_posts call above to only * include attachments. */ - if ( ! isset( $attachment->ID ) || ! wp_attachment_is_image( $attachment->ID ) ) { + if ( + ! isset( $attachment->ID ) + || ! wp_attachment_is_image( $attachment->ID ) + || ! isset( $selected_images[ $attachment->ID ] ) + ) { continue; } $image_elements = $selected_images[ $attachment->ID ]; From 25830a1f536acda7947fccf5d29d193de39379f6 Mon Sep 17 00:00:00 2001 From: Peter Petrov Date: Tue, 2 Apr 2024 14:48:37 +0300 Subject: [PATCH 02/23] Boost: Add speed score popout (#36432) * Add speed score popout * add changelog --- .../src/js/features/speed-score/speed-score.tsx | 12 +++++++++++- .../plugins/boost/changelog/add-speed-score-prompt | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/boost/changelog/add-speed-score-prompt diff --git a/projects/plugins/boost/app/assets/src/js/features/speed-score/speed-score.tsx b/projects/plugins/boost/app/assets/src/js/features/speed-score/speed-score.tsx index d9b548be4caaa..0e4a000784852 100644 --- a/projects/plugins/boost/app/assets/src/js/features/speed-score/speed-score.tsx +++ b/projects/plugins/boost/app/assets/src/js/features/speed-score/speed-score.tsx @@ -1,4 +1,8 @@ -import { getScoreLetter, didScoresChange } from '@automattic/jetpack-boost-score-api'; +import { + getScoreLetter, + didScoresChange, + getScoreMovementPercentage, +} from '@automattic/jetpack-boost-score-api'; import { BoostScoreBar, Button } from '@automattic/jetpack-components'; import { sprintf, __ } from '@wordpress/i18n'; import ContextTooltip from './context-tooltip/context-tooltip'; @@ -15,6 +19,7 @@ import { useCriticalCssState } from '$features/critical-css/lib/stores/critical- import { useLocalCriticalCssGeneratorStatus } from '$features/critical-css/local-generator/local-generator-provider'; import { queryClient } from '@automattic/jetpack-react-data-sync-client'; import ErrorBoundary from '$features/error-boundary/error-boundary'; +import PopOut from './pop-out/pop-out'; const SpeedScore = () => { const { site } = Jetpack_Boost; @@ -37,6 +42,9 @@ const SpeedScore = () => { [ data ] ); + const showScoreChangePopOut = + status === 'loaded' && ! scores.isStale && getScoreMovementPercentage( scores ); + // Mark performance history data as stale when speed scores are loaded. useEffect( () => { if ( site.online && status === 'loaded' ) { @@ -141,6 +149,8 @@ const SpeedScore = () => { { site.online && } + + ); }; diff --git a/projects/plugins/boost/changelog/add-speed-score-prompt b/projects/plugins/boost/changelog/add-speed-score-prompt new file mode 100644 index 0000000000000..3046b34da6538 --- /dev/null +++ b/projects/plugins/boost/changelog/add-speed-score-prompt @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Speed Score: Add the speed changed popup back. From 1fc216cc57a6c46be072a19af8b6be1d458b9f43 Mon Sep 17 00:00:00 2001 From: Igor Zinovyev Date: Tue, 2 Apr 2024 16:09:38 +0300 Subject: [PATCH 03/23] Fix deprecation warnings in the Color library. (#36680) * Use floor instead of int to avoid deprecation notices. * CHangelog. * Making Phan happy. * Using intval instead of floor. --- projects/plugins/jetpack/_inc/lib/class.color.php | 2 +- .../plugins/jetpack/changelog/fix-deprecation-warnings-color | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/fix-deprecation-warnings-color diff --git a/projects/plugins/jetpack/_inc/lib/class.color.php b/projects/plugins/jetpack/_inc/lib/class.color.php index 72ca02f87bd27..2ca4e02762d86 100644 --- a/projects/plugins/jetpack/_inc/lib/class.color.php +++ b/projects/plugins/jetpack/_inc/lib/class.color.php @@ -102,7 +102,7 @@ public function fromRgbInt( $red, $green, $blue ) { throw new RangeException( 'Blue value ' . $blue . ' out of valid color code range' ); } - $this->color = (int) ( ( $red << 16 ) + ( $green << 8 ) + $blue ); + $this->color = intval( ( $red << 16 ) + ( $green << 8 ) + $blue ); return $this; } diff --git a/projects/plugins/jetpack/changelog/fix-deprecation-warnings-color b/projects/plugins/jetpack/changelog/fix-deprecation-warnings-color new file mode 100644 index 0000000000000..b0d5f70b7fff5 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-deprecation-warnings-color @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Theme tools: Use integer casting method that doesn't cause deprecation notices. From b42c9013b210031370d1862b189a7caf25c15319 Mon Sep 17 00:00:00 2001 From: Dusty Reagan Date: Tue, 2 Apr 2024 09:06:42 -0500 Subject: [PATCH 04/23] Add Hosting menu to Simple sites (#36684) * Allow Simple site users access * changelog * Run tools/fixup-project-versions.sh * Supress PhanUndeclaredFunction * Update comment --- .../changelog/add-hosting-menu-to-simple | 4 ++++ .../packages/jetpack-mu-wpcom/composer.json | 2 +- .../packages/jetpack-mu-wpcom/package.json | 2 +- .../src/class-jetpack-mu-wpcom.php | 2 +- .../wpcom-site-menu/wpcom-site-menu.php | 20 +++++++++++++------ .../changelog/add-hosting-menu-to-simple | 5 +++++ .../plugins/mu-wpcom-plugin/composer.json | 2 +- .../plugins/mu-wpcom-plugin/composer.lock | 4 ++-- .../mu-wpcom-plugin/mu-wpcom-plugin.php | 2 +- projects/plugins/mu-wpcom-plugin/package.json | 2 +- 10 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/add-hosting-menu-to-simple create mode 100644 projects/plugins/mu-wpcom-plugin/changelog/add-hosting-menu-to-simple diff --git a/projects/packages/jetpack-mu-wpcom/changelog/add-hosting-menu-to-simple b/projects/packages/jetpack-mu-wpcom/changelog/add-hosting-menu-to-simple new file mode 100644 index 0000000000000..d9613ec951d9c --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/add-hosting-menu-to-simple @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Allow Simple sites access to the Hosting menu diff --git a/projects/packages/jetpack-mu-wpcom/composer.json b/projects/packages/jetpack-mu-wpcom/composer.json index f78ed35c946ae..201ba5dc1058b 100644 --- a/projects/packages/jetpack-mu-wpcom/composer.json +++ b/projects/packages/jetpack-mu-wpcom/composer.json @@ -51,7 +51,7 @@ }, "autotagger": true, "branch-alias": { - "dev-trunk": "5.22.x-dev" + "dev-trunk": "5.23.x-dev" }, "textdomain": "jetpack-mu-wpcom", "version-constants": { diff --git a/projects/packages/jetpack-mu-wpcom/package.json b/projects/packages/jetpack-mu-wpcom/package.json index a69dbbcab24e1..4d413553ab8c8 100644 --- a/projects/packages/jetpack-mu-wpcom/package.json +++ b/projects/packages/jetpack-mu-wpcom/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-mu-wpcom", - "version": "5.22.0", + "version": "5.23.0-alpha", "description": "Enhances your site with features powered by WordPress.com", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/jetpack-mu-wpcom/#readme", "bugs": { diff --git a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php index b56952836c2c2..f6a892cf61299 100644 --- a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php +++ b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php @@ -13,7 +13,7 @@ * Jetpack_Mu_Wpcom main class. */ class Jetpack_Mu_Wpcom { - const PACKAGE_VERSION = '5.22.0'; + const PACKAGE_VERSION = '5.23.0-alpha'; const PKG_DIR = __DIR__ . '/../'; const BASE_DIR = __DIR__ . '/'; const BASE_FILE = __FILE__; diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-site-menu/wpcom-site-menu.php b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-site-menu/wpcom-site-menu.php index ab7bb620b2a3e..c8941496b42c8 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-site-menu/wpcom-site-menu.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-site-menu/wpcom-site-menu.php @@ -15,13 +15,21 @@ * @return bool */ function current_user_has_wpcom_account() { - $user_id = get_current_user_id(); - $connection_manager = new Connection_Manager(); - $wpcom_user_data = $connection_manager->get_connected_user_data( $user_id ); - if ( ! isset( $wpcom_user_data['ID'] ) ) { - return false; + $user_id = get_current_user_id(); + + if ( function_exists( '\A8C\Billingdaddy\Users\get_wpcom_user' ) ) { + // On Simple sites, use get_wpcom_user function to check if the user has a WordPress.com account. + // @phan-suppress-next-line PhanUndeclaredFunction + $user = \A8C\Billingdaddy\Users\get_wpcom_user( $user_id ); + $has_account = isset( $user->ID ); + } else { + // On Atomic sites, use the Connection Manager to check if the user has a WordPress.com account. + $connection_manager = new Connection_Manager(); + $wpcom_user_data = $connection_manager->get_connected_user_data( $user_id ); + $has_account = isset( $wpcom_user_data['ID'] ); } - return true; + + return $has_account; } /** diff --git a/projects/plugins/mu-wpcom-plugin/changelog/add-hosting-menu-to-simple b/projects/plugins/mu-wpcom-plugin/changelog/add-hosting-menu-to-simple new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/mu-wpcom-plugin/changelog/add-hosting-menu-to-simple @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/mu-wpcom-plugin/composer.json b/projects/plugins/mu-wpcom-plugin/composer.json index 7e19cbcb8bd7e..89f22976f81ba 100644 --- a/projects/plugins/mu-wpcom-plugin/composer.json +++ b/projects/plugins/mu-wpcom-plugin/composer.json @@ -46,6 +46,6 @@ ] }, "config": { - "autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ2_1_11" + "autoloader-suffix": "d9d132a783958a00a2c7cccff60ca42d_jetpack_mu_wpcom_pluginⓥ2_1_12_alpha" } } diff --git a/projects/plugins/mu-wpcom-plugin/composer.lock b/projects/plugins/mu-wpcom-plugin/composer.lock index d0f58a55b1ba1..3c727486d59fb 100644 --- a/projects/plugins/mu-wpcom-plugin/composer.lock +++ b/projects/plugins/mu-wpcom-plugin/composer.lock @@ -129,7 +129,7 @@ "dist": { "type": "path", "url": "../../packages/jetpack-mu-wpcom", - "reference": "0b49970bdde8c3c05388592c86db00b2888f6dd4" + "reference": "6afd8e193ad433131247e6cba33ba6d3d926c055" }, "require": { "automattic/jetpack-assets": "@dev", @@ -152,7 +152,7 @@ }, "autotagger": true, "branch-alias": { - "dev-trunk": "5.22.x-dev" + "dev-trunk": "5.23.x-dev" }, "textdomain": "jetpack-mu-wpcom", "version-constants": { diff --git a/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php b/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php index 7defba629a528..7a143d6a489ab 100644 --- a/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php +++ b/projects/plugins/mu-wpcom-plugin/mu-wpcom-plugin.php @@ -3,7 +3,7 @@ * * Plugin Name: WordPress.com Features * Description: Test plugin for the jetpack-mu-wpcom package - * Version: 2.1.11 + * Version: 2.1.12-alpha * Author: Automattic * License: GPLv2 or later * Text Domain: jetpack-mu-wpcom-plugin diff --git a/projects/plugins/mu-wpcom-plugin/package.json b/projects/plugins/mu-wpcom-plugin/package.json index 3be65551811cb..b13e00b3bdeed 100644 --- a/projects/plugins/mu-wpcom-plugin/package.json +++ b/projects/plugins/mu-wpcom-plugin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-mu-wpcom-plugin", - "version": "2.1.11", + "version": "2.1.12-alpha", "description": "Test plugin for the jetpack-mu-wpcom package", "homepage": "https://jetpack.com", "bugs": { From 2454b34e9dae3a03f6ebc7eeeda87830973bad69 Mon Sep 17 00:00:00 2001 From: Juanma Rodriguez Escriche Date: Tue, 2 Apr 2024 16:22:05 +0200 Subject: [PATCH 05/23] Sync send queue size for pull jobs (#36693) * Send queue size for pull jobs * Changelog * Version bump --- .../sync/changelog/update-sync-send-queue-size-for-pull-jobs | 4 ++++ projects/packages/sync/composer.json | 2 +- projects/packages/sync/src/class-package-version.php | 2 +- projects/packages/sync/src/class-rest-sender.php | 1 + .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ .../plugins/automattic-for-agencies-client/composer.lock | 4 ++-- .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ projects/plugins/backup/composer.lock | 4 ++-- .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ projects/plugins/boost/composer.lock | 4 ++-- .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ projects/plugins/jetpack/composer.lock | 4 ++-- .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ projects/plugins/migration/composer.lock | 4 ++-- .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ projects/plugins/protect/composer.lock | 4 ++-- .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ projects/plugins/search/composer.lock | 4 ++-- .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ projects/plugins/social/composer.lock | 4 ++-- .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ projects/plugins/starter-plugin/composer.lock | 4 ++-- .../changelog/update-sync-send-queue-size-for-pull-jobs | 5 +++++ projects/plugins/videopress/composer.lock | 4 ++-- 24 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 projects/packages/sync/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/automattic-for-agencies-client/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/backup/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/boost/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/jetpack/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/migration/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/protect/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/search/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/social/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/starter-plugin/changelog/update-sync-send-queue-size-for-pull-jobs create mode 100644 projects/plugins/videopress/changelog/update-sync-send-queue-size-for-pull-jobs diff --git a/projects/packages/sync/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/packages/sync/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..f51c3b6974873 --- /dev/null +++ b/projects/packages/sync/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,4 @@ +Significance: minor +Type: changed + +Sync: Sending queue size for pull jobs. diff --git a/projects/packages/sync/composer.json b/projects/packages/sync/composer.json index 6561c5379e52b..1dffed74f2ede 100644 --- a/projects/packages/sync/composer.json +++ b/projects/packages/sync/composer.json @@ -58,7 +58,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "config": { diff --git a/projects/packages/sync/src/class-package-version.php b/projects/packages/sync/src/class-package-version.php index 1835261373fb9..97d884941be04 100644 --- a/projects/packages/sync/src/class-package-version.php +++ b/projects/packages/sync/src/class-package-version.php @@ -12,7 +12,7 @@ */ class Package_Version { - const PACKAGE_VERSION = '2.10.5'; + const PACKAGE_VERSION = '2.11.0-alpha'; const PACKAGE_SLUG = 'sync'; diff --git a/projects/packages/sync/src/class-rest-sender.php b/projects/packages/sync/src/class-rest-sender.php index 5ceb0b85e5e8e..2221b8506bd0e 100644 --- a/projects/packages/sync/src/class-rest-sender.php +++ b/projects/packages/sync/src/class-rest-sender.php @@ -74,6 +74,7 @@ public function queue_pull( $queue_name, $number_of_items, $args ) { 'skipped_items' => $skipped_items_ids, 'codec' => $encode ? $sender->get_codec()->name() : null, 'sent_timestamp' => time(), + 'queue_size' => $queue->size(), ); } diff --git a/projects/plugins/automattic-for-agencies-client/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/automattic-for-agencies-client/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/automattic-for-agencies-client/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/automattic-for-agencies-client/composer.lock b/projects/plugins/automattic-for-agencies-client/composer.lock index cf0e87d73031b..6935d2e263250 100644 --- a/projects/plugins/automattic-for-agencies-client/composer.lock +++ b/projects/plugins/automattic-for-agencies-client/composer.lock @@ -991,7 +991,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1023,7 +1023,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { diff --git a/projects/plugins/backup/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/backup/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/backup/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/backup/composer.lock b/projects/plugins/backup/composer.lock index 819c29065a9f6..00120f30b9e85 100644 --- a/projects/plugins/backup/composer.lock +++ b/projects/plugins/backup/composer.lock @@ -1544,7 +1544,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1576,7 +1576,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { diff --git a/projects/plugins/boost/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/boost/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/boost/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/boost/composer.lock b/projects/plugins/boost/composer.lock index caf74bec3238a..9126b37aff167 100644 --- a/projects/plugins/boost/composer.lock +++ b/projects/plugins/boost/composer.lock @@ -1534,7 +1534,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1566,7 +1566,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { diff --git a/projects/plugins/jetpack/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/jetpack/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..a1c1831fa1ef7 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Updated composer.lock. + + diff --git a/projects/plugins/jetpack/composer.lock b/projects/plugins/jetpack/composer.lock index b93ec22c35ba4..cd933a05c26d0 100644 --- a/projects/plugins/jetpack/composer.lock +++ b/projects/plugins/jetpack/composer.lock @@ -2452,7 +2452,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -2484,7 +2484,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { diff --git a/projects/plugins/migration/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/migration/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/migration/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/migration/composer.lock b/projects/plugins/migration/composer.lock index 1e0e6d3fe4fe4..71100611abd8e 100644 --- a/projects/plugins/migration/composer.lock +++ b/projects/plugins/migration/composer.lock @@ -1544,7 +1544,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1576,7 +1576,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { diff --git a/projects/plugins/protect/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/protect/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/protect/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/protect/composer.lock b/projects/plugins/protect/composer.lock index aa41a18417015..be00575f4727e 100644 --- a/projects/plugins/protect/composer.lock +++ b/projects/plugins/protect/composer.lock @@ -1457,7 +1457,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1489,7 +1489,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { diff --git a/projects/plugins/search/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/search/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/search/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/search/composer.lock b/projects/plugins/search/composer.lock index 6ac85adb2f0e2..3277741ac4619 100644 --- a/projects/plugins/search/composer.lock +++ b/projects/plugins/search/composer.lock @@ -1548,7 +1548,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1580,7 +1580,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { diff --git a/projects/plugins/social/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/social/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/social/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/social/composer.lock b/projects/plugins/social/composer.lock index 702e696fec4e8..cc60d935f899d 100644 --- a/projects/plugins/social/composer.lock +++ b/projects/plugins/social/composer.lock @@ -1539,7 +1539,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1571,7 +1571,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { diff --git a/projects/plugins/starter-plugin/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/starter-plugin/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/starter-plugin/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/starter-plugin/composer.lock b/projects/plugins/starter-plugin/composer.lock index 7c4d246be75c3..a5cbf5f002706 100644 --- a/projects/plugins/starter-plugin/composer.lock +++ b/projects/plugins/starter-plugin/composer.lock @@ -1400,7 +1400,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1432,7 +1432,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { diff --git a/projects/plugins/videopress/changelog/update-sync-send-queue-size-for-pull-jobs b/projects/plugins/videopress/changelog/update-sync-send-queue-size-for-pull-jobs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/videopress/changelog/update-sync-send-queue-size-for-pull-jobs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/videopress/composer.lock b/projects/plugins/videopress/composer.lock index c8765c54f672d..5d6cc59b70d0d 100644 --- a/projects/plugins/videopress/composer.lock +++ b/projects/plugins/videopress/composer.lock @@ -1400,7 +1400,7 @@ "dist": { "type": "path", "url": "../../packages/sync", - "reference": "fef540b80efa9abea56562486e0ee296305cee66" + "reference": "6f1c78637e77424cfaa762850842d08d3f79b4d0" }, "require": { "automattic/jetpack-connection": "@dev", @@ -1432,7 +1432,7 @@ "link-template": "https://github.com/Automattic/jetpack-sync/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "2.10.x-dev" + "dev-trunk": "2.11.x-dev" } }, "autoload": { From ddd4486f53ab585f7c4fa5c081b816df19aaee6b Mon Sep 17 00:00:00 2001 From: Dylan Munson <65001528+CodeyGuyDylan@users.noreply.github.com> Date: Tue, 2 Apr 2024 09:57:46 -0600 Subject: [PATCH 06/23] Fix/cache on front end boost scores (#36700) * Use site URL with protocol to add to correct cache * changelog * Fixup project versions * escape url --- .../product-cards-section/boost-card/boost-speed-score.tsx | 2 +- .../my-jetpack/changelog/fix-cache-on-front-end-boost-scores | 4 ++++ projects/packages/my-jetpack/global.d.ts | 1 + projects/packages/my-jetpack/package.json | 2 +- projects/packages/my-jetpack/src/class-initializer.php | 3 ++- 5 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 projects/packages/my-jetpack/changelog/fix-cache-on-front-end-boost-scores diff --git a/projects/packages/my-jetpack/_inc/components/product-cards-section/boost-card/boost-speed-score.tsx b/projects/packages/my-jetpack/_inc/components/product-cards-section/boost-card/boost-speed-score.tsx index d396706a8cb0f..a21844df45904 100644 --- a/projects/packages/my-jetpack/_inc/components/product-cards-section/boost-card/boost-speed-score.tsx +++ b/projects/packages/my-jetpack/_inc/components/product-cards-section/boost-card/boost-speed-score.tsx @@ -25,7 +25,7 @@ const BoostSpeedScore: FC = () => { const [ isTooltipVisible, setIsTooltipVisible ] = useState( false ); const isMobileViewport = useViewportMatch( 'medium', '<' ); - const { siteSuffix: siteUrl = '', latestBoostSpeedScores } = getMyJetpackWindowInitialState(); + const { siteUrl = '', latestBoostSpeedScores } = getMyJetpackWindowInitialState(); const { apiRoot, apiNonce, isSiteConnected } = useMyJetpackConnection(); const getAverageSpeedScore = ( mobileScore, desktopScore ) => { diff --git a/projects/packages/my-jetpack/changelog/fix-cache-on-front-end-boost-scores b/projects/packages/my-jetpack/changelog/fix-cache-on-front-end-boost-scores new file mode 100644 index 0000000000000..007dd3bcb3835 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/fix-cache-on-front-end-boost-scores @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix cache on front end request for boost speed scores diff --git a/projects/packages/my-jetpack/global.d.ts b/projects/packages/my-jetpack/global.d.ts index c656444528a05..5ab9263630d46 100644 --- a/projects/packages/my-jetpack/global.d.ts +++ b/projects/packages/my-jetpack/global.d.ts @@ -6,6 +6,7 @@ declare module '*.scss'; interface Window { myJetpackInitialState?: { siteSuffix: string; + siteUrl: string; latestBoostSpeedScores: { scores: { desktop: number; diff --git a/projects/packages/my-jetpack/package.json b/projects/packages/my-jetpack/package.json index 1f1a729c01ed2..5cd4224096b84 100644 --- a/projects/packages/my-jetpack/package.json +++ b/projects/packages/my-jetpack/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-my-jetpack", - "version": "4.20.2", + "version": "4.20.3-alpha", "description": "WP Admin page with information and configuration shared among all Jetpack stand-alone plugins", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/my-jetpack/#readme", "bugs": { diff --git a/projects/packages/my-jetpack/src/class-initializer.php b/projects/packages/my-jetpack/src/class-initializer.php index 9d23333d6623f..906ffb14f45ff 100644 --- a/projects/packages/my-jetpack/src/class-initializer.php +++ b/projects/packages/my-jetpack/src/class-initializer.php @@ -36,7 +36,7 @@ class Initializer { * * @var string */ - const PACKAGE_VERSION = '4.20.2'; + const PACKAGE_VERSION = '4.20.3-alpha'; /** * HTML container ID for the IDC screen on My Jetpack page. @@ -214,6 +214,7 @@ public static function enqueue_scripts() { 'myJetpackCheckoutUri' => admin_url( 'admin.php?page=my-jetpack' ), 'topJetpackMenuItemUrl' => Admin_Menu::get_top_level_menu_item_url(), 'siteSuffix' => ( new Status() )->get_site_suffix(), + 'siteUrl' => esc_url( get_site_url() ), 'blogID' => Connection_Manager::get_site_id( true ), 'myJetpackVersion' => self::PACKAGE_VERSION, 'myJetpackFlags' => self::get_my_jetpack_flags(), From 0ad46008bb7b7b4af98da9c577e1ddd14cef7f8e Mon Sep 17 00:00:00 2001 From: jboland88 <18016357+jboland88@users.noreply.github.com> Date: Tue, 2 Apr 2024 16:32:18 -0400 Subject: [PATCH 07/23] Fix/tier upgrades my jetpack (#36705) * Handle non-free tiers correctly in post activation callback * changelog * Fix regressions for other products --- .../my-jetpack/_inc/components/product-interstitial/index.jsx | 4 +++- .../my-jetpack/changelog/fix-tier-upgrades-my-jetpack | 4 ++++ projects/packages/my-jetpack/src/products/class-product.php | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 projects/packages/my-jetpack/changelog/fix-tier-upgrades-my-jetpack diff --git a/projects/packages/my-jetpack/_inc/components/product-interstitial/index.jsx b/projects/packages/my-jetpack/_inc/components/product-interstitial/index.jsx index 3158747589d64..cada7e66644ca 100644 --- a/projects/packages/my-jetpack/_inc/components/product-interstitial/index.jsx +++ b/projects/packages/my-jetpack/_inc/components/product-interstitial/index.jsx @@ -145,7 +145,9 @@ export default function ProductInterstitial( { const isFree = tier ? product?.pricingForUi?.tiers?.[ tier ]?.isFree : product?.pricingForUi?.isFree; - const needsPurchase = ! isFree && ! hasPaidPlanForProduct; + const isUpgradeToHigherTier = + tier && product?.pricingForUi?.tiers?.[ tier ] && ! isFree && product?.isUpgradable; + const needsPurchase = ( ! isFree && ! hasPaidPlanForProduct ) || isUpgradeToHigherTier; // If the product is CRM, redirect the user to the Jetpack CRM pricing page. // This is done because CRM is not part of the WP billing system diff --git a/projects/packages/my-jetpack/changelog/fix-tier-upgrades-my-jetpack b/projects/packages/my-jetpack/changelog/fix-tier-upgrades-my-jetpack new file mode 100644 index 0000000000000..57d5dfd28b497 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/fix-tier-upgrades-my-jetpack @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +fix tier upgrades in my Jetpack diff --git a/projects/packages/my-jetpack/src/products/class-product.php b/projects/packages/my-jetpack/src/products/class-product.php index 0101f4594e53a..def5da509d9cd 100644 --- a/projects/packages/my-jetpack/src/products/class-product.php +++ b/projects/packages/my-jetpack/src/products/class-product.php @@ -141,6 +141,7 @@ public static function get_info() { 'pricing_for_ui' => static::get_pricing_for_ui(), 'is_bundle' => static::is_bundle_product(), 'is_plugin_active' => static::is_plugin_active(), + 'is_upgradable' => static::is_upgradable(), 'is_upgradable_by_bundle' => static::is_upgradable_by_bundle(), 'supported_products' => static::get_supported_products(), 'wpcom_product_slug' => static::get_wpcom_product_slug(), From a1c1188518843f555a12a5adc5f662d2cc4ded58 Mon Sep 17 00:00:00 2001 From: Robert Felty Date: Tue, 2 Apr 2024 23:14:28 +0200 Subject: [PATCH 08/23] Fix PHP 8.1 error in youtube shortcode (#36699) * Fix youtube shortcode error when getting unexpected input --- .../plugins/jetpack/changelog/fix-youtube-shortcode-error | 4 ++++ projects/plugins/jetpack/modules/shortcodes/youtube.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/fix-youtube-shortcode-error diff --git a/projects/plugins/jetpack/changelog/fix-youtube-shortcode-error b/projects/plugins/jetpack/changelog/fix-youtube-shortcode-error new file mode 100644 index 0000000000000..95afb73ab1397 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-youtube-shortcode-error @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +PHP 8.1: Fix error trying to run preg_split on array diff --git a/projects/plugins/jetpack/modules/shortcodes/youtube.php b/projects/plugins/jetpack/modules/shortcodes/youtube.php index 1d1ef2a55eb22..14acabc318087 100644 --- a/projects/plugins/jetpack/modules/shortcodes/youtube.php +++ b/projects/plugins/jetpack/modules/shortcodes/youtube.php @@ -235,7 +235,7 @@ function youtube_id( $url ) { } elseif ( isset( $args['t'] ) ) { if ( is_numeric( $args['t'] ) ) { $start = (int) $args['t']; - } else { + } elseif ( is_string( $args['t'] ) ) { $time_pieces = preg_split( '/(?<=\D)(?=\d+)/', $args['t'] ); foreach ( $time_pieces as $time_piece ) { From 958dc7f1006c5b69d07d03d54873de7e14e7d1ed Mon Sep 17 00:00:00 2001 From: Douglas Henri Date: Tue, 2 Apr 2024 18:18:03 -0300 Subject: [PATCH 09/23] Jetpack AI Assistant: Remove old deadcode from image modal (#36683) * remove old image generation * remove categories loading flag * changelog --- ...update-jetpack-ai-remove-unused-code-image | 4 + .../components/image-with-select/index.js | 41 ------ .../components/toolbar-controls/index.js | 15 +-- .../extensions/blocks/ai-assistant/edit.js | 125 +----------------- .../use-suggestions-from-openai/index.js | 3 - .../blocks/ai-assistant/lib/image/index.js | 47 ------- 6 files changed, 10 insertions(+), 225 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/update-jetpack-ai-remove-unused-code-image delete mode 100644 projects/plugins/jetpack/extensions/blocks/ai-assistant/components/image-with-select/index.js delete mode 100644 projects/plugins/jetpack/extensions/blocks/ai-assistant/lib/image/index.js diff --git a/projects/plugins/jetpack/changelog/update-jetpack-ai-remove-unused-code-image b/projects/plugins/jetpack/changelog/update-jetpack-ai-remove-unused-code-image new file mode 100644 index 0000000000000..eb661487c2e9b --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-jetpack-ai-remove-unused-code-image @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Jetpack AI Assistant: Remove old deadcode from image modal diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/image-with-select/index.js b/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/image-with-select/index.js deleted file mode 100644 index 2979940846e25..0000000000000 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/image-with-select/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/* - * External dependencies - */ -import { Button, Flex, FlexBlock, FlexItem } from '@wordpress/components'; -import { __ } from '@wordpress/i18n'; - -const ImageWithSelect = ( { image, inModal = false, saveImage, setImageModal } ) => { - return ( - - { inModal && ( - - - - ) } - - setImageModal( image ) } - /> - - { ! inModal && ( - - - - - - - - ) } - - ); -}; - -export default ImageWithSelect; diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/toolbar-controls/index.js b/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/toolbar-controls/index.js index cea0738ed0816..f664c6da23534 100644 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/toolbar-controls/index.js +++ b/projects/plugins/jetpack/extensions/blocks/ai-assistant/components/toolbar-controls/index.js @@ -4,7 +4,7 @@ import { BlockControls } from '@wordpress/block-editor'; import { ToolbarButton, ToolbarGroup } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -import { image, update, check } from '@wordpress/icons'; +import { update, check } from '@wordpress/icons'; /* * Internal dependencies */ @@ -14,15 +14,11 @@ import ImproveToolbarDropdownMenu from '../improve-dropdown-control'; import PromptTemplatesControl from '../prompt-templates-control'; import ToneToolbarDropdownMenu from '../tone-dropdown-control'; -// Consider to enable when we have image support -const isImageGenerationEnabled = false; - const ToolbarControls = ( { contentIsLoaded, getSuggestionFromOpenAI, retryRequest, handleAcceptContent, - handleImageRequest, handleTryAgain, showRetry, contentBefore, @@ -122,15 +118,6 @@ const ToolbarControls = ( { ) } ) } - - { isImageGenerationEnabled && ! showRetry && ! contentIsLoaded && ( - // Image/text toggle - - - { __( 'Ask AI for an image', 'jetpack' ) } - - - ) } ); diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js b/projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js index f7f2c7f5795ca..a8309ea6d1de8 100644 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js +++ b/projects/plugins/jetpack/extensions/blocks/ai-assistant/edit.js @@ -4,10 +4,8 @@ import { AIControl, UpgradeMessage } from '@automattic/jetpack-ai-client'; import { useAnalytics } from '@automattic/jetpack-shared-extension-utils'; import { useBlockProps, useInnerBlocksProps, InspectorControls } from '@wordpress/block-editor'; -import { rawHandler, createBlock, parse } from '@wordpress/blocks'; +import { rawHandler, parse } from '@wordpress/blocks'; import { - Flex, - FlexBlock, Modal, Notice, PanelBody, @@ -32,7 +30,6 @@ import { USAGE_PANEL_PLACEMENT_BLOCK_SETTINGS_SIDEBAR } from '../../plugins/ai-a import { PLAN_TYPE_FREE, usePlanType } from '../../shared/use-plan-type'; import ConnectPrompt from './components/connect-prompt'; import FeedbackControl from './components/feedback-control'; -import ImageWithSelect from './components/image-with-select'; import ToolbarControls from './components/toolbar-controls'; import UpgradePrompt from './components/upgrade-prompt'; import { getStoreBlockId } from './extensions/ai-assistant/with-ai-assistant'; @@ -40,7 +37,6 @@ import useAICheckout from './hooks/use-ai-checkout'; import useAiFeature from './hooks/use-ai-feature'; import useSuggestionsFromOpenAI from './hooks/use-suggestions-from-openai'; import { isUserConnected } from './lib/connection'; -import { getImagesFromOpenAI } from './lib/image'; import { getInitialSystemPrompt } from './lib/prompt'; import './editor.scss'; @@ -54,27 +50,16 @@ const isPlaygroundVisible = export default function AIAssistantEdit( { attributes, setAttributes, clientId, isSelected } ) { const [ errorData, setError ] = useState( {} ); - const [ loadingImages, setLoadingImages ] = useState( false ); - const [ resultImages, setResultImages ] = useState( [] ); - const [ imageModal, setImageModal ] = useState( null ); const [ errorDismissed, setErrorDismissed ] = useState( null ); const { tracks } = useAnalytics(); - const postId = useSelect( select => select( 'core/editor' ).getCurrentPostId() ); const { getBlock } = useSelect( 'core/block-editor' ); const aiControlRef = useRef( null ); const blockRef = useRef( null ); - const { replaceBlocks, replaceBlock, removeBlock } = useDispatch( 'core/block-editor' ); + const { replaceBlocks, removeBlock } = useDispatch( 'core/block-editor' ); const { editPost } = useDispatch( 'core/editor' ); - const { mediaUpload } = useSelect( select => { - const { getSettings } = select( 'core/block-editor' ); - const settings = getSettings(); - return { - mediaUpload: settings.mediaUpload, - }; - }, [] ); const { isOverLimit, @@ -112,7 +97,6 @@ export default function AIAssistantEdit( { attributes, setAttributes, clientId, const contentRef = useRef( null ); const { - isLoadingCategories, isLoadingCompletion, wasCompletionJustRequested, getSuggestionFromOpenAI, @@ -226,52 +210,8 @@ export default function AIAssistantEdit( { attributes, setAttributes, clientId, setAttributes( { requestingState } ); }, [ requestingState, setAttributes ] ); - const saveImage = async image => { - if ( loadingImages ) { - return; - } - setLoadingImages( true ); - setError( {} ); - - // First convert image to a proper blob file - const resp = await fetch( image ); - const blob = await resp.blob(); - const file = new File( [ blob ], 'jetpack_ai_image.png', { - type: 'image/png', - } ); - // Actually upload the image - mediaUpload( { - filesList: [ file ], - onFileChange: ( [ img ] ) => { - if ( ! img.id ) { - // Without this image gets uploaded twice - return; - } - replaceBlock( - clientId, - createBlock( 'core/image', { - url: img.url, - caption: attributes.requestedPrompt, - alt: attributes.requestedPrompt, - } ) - ); - }, - allowedTypes: [ 'image' ], - onError: message => { - // eslint-disable-next-line no-console - console.error( message ); - setLoadingImages( false ); - }, - } ); - tracks.recordEvent( 'jetpack_ai_dalle_generation_upload', { - post_id: postId, - } ); - }; - const useGutenbergSyntax = attributes?.useGutenbergSyntax; - // Waiting state means there is nothing to be done until it resolves - const isWaitingState = isLoadingCompletion || isLoadingCategories; // Content is loaded const contentIsLoaded = !! attributes.content; @@ -418,26 +358,6 @@ export default function AIAssistantEdit( { attributes, setAttributes, clientId, tracks.recordEvent( 'jetpack_ai_assistant_block_stop', { feature: 'ai-assistant' } ); }; - const handleImageRequest = () => { - setResultImages( [] ); - setError( {} ); - - getImagesFromOpenAI( - attributes.userPrompt.trim() === '' - ? __( 'What would you like to see?', 'jetpack' ) - : attributes.userPrompt, - setAttributes, - setLoadingImages, - setResultImages, - setError, - postId - ); - - tracks.recordEvent( 'jetpack_ai_dalle_generation', { - post_id: postId, - } ); - }; - /* * Custom prompt modal */ @@ -586,15 +506,14 @@ export default function AIAssistantEdit( { attributes, setAttributes, clientId, ) } - { ! isWaitingState && connected && ! requireUpgrade && ( + { ! isLoadingCompletion && connected && ! requireUpgrade && ( 0 } @@ -647,40 +566,6 @@ export default function AIAssistantEdit( { attributes, setAttributes, clientId, ) : null } /> - - { ! loadingImages && resultImages.length > 0 && ( - - - { attributes.requestedPrompt } - - - { __( 'Please choose your image', 'jetpack' ) } - - - { resultImages.map( image => ( - - ) ) } - - - ) } - - { ! loadingImages && imageModal && ( - setImageModal( null ) }> - - - ) } ); diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-suggestions-from-openai/index.js b/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-suggestions-from-openai/index.js index 2ab141bbb9fbc..d3378332b8cba 100644 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-suggestions-from-openai/index.js +++ b/projects/plugins/jetpack/extensions/blocks/ai-assistant/hooks/use-suggestions-from-openai/index.js @@ -37,7 +37,6 @@ const useSuggestionsFromOpenAI = ( { blockRef, contentRef, } ) => { - const [ isLoadingCategories, setIsLoadingCategories ] = useState( false ); const [ isLoadingCompletion, setIsLoadingCompletion ] = useState( false ); const [ wasCompletionJustRequested, setWasCompletionJustRequested ] = useState( false ); const [ showRetry, setShowRetry ] = useState( false ); @@ -485,10 +484,8 @@ const useSuggestionsFromOpenAI = ( { } return { - isLoadingCategories, isLoadingCompletion, wasCompletionJustRequested, - setIsLoadingCategories, setShowRetry, showRetry, postTitle: currentPostTitle, diff --git a/projects/plugins/jetpack/extensions/blocks/ai-assistant/lib/image/index.js b/projects/plugins/jetpack/extensions/blocks/ai-assistant/lib/image/index.js deleted file mode 100644 index 8bf7bb044346d..0000000000000 --- a/projects/plugins/jetpack/extensions/blocks/ai-assistant/lib/image/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/* - * External dependencies - */ -import apiFetch from '@wordpress/api-fetch'; -import { __ } from '@wordpress/i18n'; - -export function getImagesFromOpenAI( - prompt, - setAttributes, - setLoadingImages, - setResultImages, - setErrorMessage, - postId -) { - setLoadingImages( true ); - setErrorMessage( null ); - setAttributes( { requestedPrompt: prompt } ); // This will prevent double submitting. - - apiFetch( { - path: '/wpcom/v2/jetpack-ai/images/generations', - method: 'POST', - data: { - prompt, - post_id: postId, - }, - } ) - .then( res => { - setLoadingImages( false ); - const images = res.data.map( image => { - return 'data:image/png;base64,' + image.b64_json; - } ); - setResultImages( images ); - } ) - .catch( e => { - if ( e.message ) { - setErrorMessage( e.message ); // Message was already translated by the backend - } else { - setErrorMessage( - __( - 'Whoops, we have encountered an error. AI is like really, really hard and this is an experimental feature. Please try again later.', - 'jetpack' - ) - ); - } - setLoadingImages( false ); - } ); -} From 07a39b57193017e6e9bf16974c9b33a58c3a96f0 Mon Sep 17 00:00:00 2001 From: Ian Ramos <5714212+IanRamosC@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:36:09 -0300 Subject: [PATCH 10/23] Update My Jetpack Notice behavior (#36614) * Adjust types and notice behavior * changelog --- .../_inc/components/notice/index.tsx | 27 ++++++++++--------- .../_inc/context/notices/noticeContext.tsx | 6 +++++ .../my-jetpack/_inc/context/notices/types.ts | 14 ++++++---- .../update-connection-and-notice-behavior | 4 +++ 4 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 projects/packages/my-jetpack/changelog/update-connection-and-notice-behavior diff --git a/projects/packages/my-jetpack/_inc/components/notice/index.tsx b/projects/packages/my-jetpack/_inc/components/notice/index.tsx index be8e4c3819238..c55250e1c1940 100644 --- a/projects/packages/my-jetpack/_inc/components/notice/index.tsx +++ b/projects/packages/my-jetpack/_inc/components/notice/index.tsx @@ -7,13 +7,12 @@ import { __ } from '@wordpress/i18n'; import { close } from '@wordpress/icons'; import classnames from 'classnames'; import { useCallback } from 'react'; -import type { NoticeAction, NoticeProps } from '@wordpress/components/src/notice/types'; +import type { NoticeButtonAction } from '../../context/notices/types'; +import type { NoticeProps } from '@wordpress/components/src/notice/types'; import type { ReactNode, Component } from 'react'; import './styles.scss'; -type NoticeButtonAction = NoticeAction & { isLoading?: boolean; isDisabled?: boolean }; - type MyJetpackNoticeProps = NoticeProps & { isRedBubble: boolean; }; @@ -44,15 +43,15 @@ function getStatusLabel( status: NoticeProps[ 'status' ] ): string { /** * Notice component based on the one from @wordpress/components. * - * @param {object} props - The properties. - * @param {string} props.className - The class name. - * @param {string} props.status - The message status: 'warning' | 'success' | 'error' | 'info'. - * @param {ReactNode} props.children - Children element - * @param {Function} props.onRemove - The function to call when the notice is removed. - * @param {boolean} props.isDismissible - Whether the notice can be dismissed. - * @param {boolean} props.isRedBubble - Whether the notice is tied to the red bubble notification. - * @param {Array} props.actions - An array of actions (buttons) to display in the notice. - * @param {Function} props.onDismiss - The function to call when the notice is dismissed. + * @param {object} props - The properties. + * @param {string} props.className - The class name. + * @param {string} props.status - The message status: 'warning' | 'success' | 'error' | 'info'. + * @param {ReactNode} props.children - Children element + * @param {Function} props.onRemove - The function to call when the notice is removed. + * @param {boolean} props.isDismissible - Whether the notice can be dismissed. + * @param {boolean} props.isRedBubble - Whether the notice is tied to the red bubble notification. + * @param {Array} props.actions - An array of actions (buttons) to display in the notice. + * @param {Function} props.onDismiss - The function to call when the notice is dismissed. * * @returns {Component} The `Notice` component. */ @@ -96,9 +95,11 @@ function Notice( { url, isLoading = false, isDisabled = false, + loadingText, }: NoticeButtonAction, index ) => { + const loadingContent = loadingText || ; let computedVariant = variant; if ( variant !== 'primary' && ! noDefaultClasses ) { computedVariant = ! url ? 'secondary' : 'link'; @@ -116,7 +117,7 @@ function Notice( { className={ classnames( 'components-notice__action', buttonCustomClasses ) } disabled={ isLoading || isDisabled } > - { isLoading ? : label } + { isLoading ? loadingContent : label } ); } diff --git a/projects/packages/my-jetpack/_inc/context/notices/noticeContext.tsx b/projects/packages/my-jetpack/_inc/context/notices/noticeContext.tsx index 5cca2863080db..8718184d3ff25 100644 --- a/projects/packages/my-jetpack/_inc/context/notices/noticeContext.tsx +++ b/projects/packages/my-jetpack/_inc/context/notices/noticeContext.tsx @@ -13,6 +13,7 @@ const defaultNotice: Notice = { export const NoticeContext = createContext< NoticeContextType >( { currentNotice: defaultNotice, setNotice: null, + resetNotice: null, } ); // Maybe todo: Add a clearNotice type function to remove any active notices @@ -27,11 +28,16 @@ const NoticeContextProvider = ( { children } ) => { } }; + const resetNotice = () => { + setCurrentNotice( defaultNotice ); + }; + return ( { children } diff --git a/projects/packages/my-jetpack/_inc/context/notices/types.ts b/projects/packages/my-jetpack/_inc/context/notices/types.ts index 67ddce3894480..44a7588b06faf 100644 --- a/projects/packages/my-jetpack/_inc/context/notices/types.ts +++ b/projects/packages/my-jetpack/_inc/context/notices/types.ts @@ -1,14 +1,17 @@ +import type { NoticeAction } from '@wordpress/components/src/notice/types'; import type { Dispatch, SetStateAction } from 'react'; +export type NoticeButtonAction = NoticeAction & { + isLoading?: boolean; + loadingText?: string; + isDisabled?: boolean; +}; + export type Notice = { message: string; options: { status: string; - actions?: { - label: string; - onClick: () => void; - noDefaultClasses?: boolean; - }[]; + actions?: NoticeButtonAction[]; priority: number; isRedBubble?: boolean; }; @@ -17,4 +20,5 @@ export type Notice = { export type NoticeContextType< T = Notice > = { currentNotice: T; setNotice: Dispatch< SetStateAction< T > > | null; + resetNotice: () => void; }; diff --git a/projects/packages/my-jetpack/changelog/update-connection-and-notice-behavior b/projects/packages/my-jetpack/changelog/update-connection-and-notice-behavior new file mode 100644 index 0000000000000..c844fa19e8dac --- /dev/null +++ b/projects/packages/my-jetpack/changelog/update-connection-and-notice-behavior @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +My Jetpack: update Notice component to allow adding a loading text when an action is in a loading state. Add a new resetNotice action to NoticeContext From a03316d169f080e29e8759865c7d8d97af0f5b50 Mon Sep 17 00:00:00 2001 From: Douglas Henri Date: Wed, 3 Apr 2024 02:21:35 -0300 Subject: [PATCH 11/23] VideoPress: Update plugin readme (#36708) * tweak the plugin readme to expected limits * changelog --- .../plugins/videopress/changelog/update-videopress-readme | 4 ++++ projects/plugins/videopress/readme.txt | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 projects/plugins/videopress/changelog/update-videopress-readme diff --git a/projects/plugins/videopress/changelog/update-videopress-readme b/projects/plugins/videopress/changelog/update-videopress-readme new file mode 100644 index 0000000000000..d6fbada9931b4 --- /dev/null +++ b/projects/plugins/videopress/changelog/update-videopress-readme @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +VideoPress: Update plugin readme diff --git a/projects/plugins/videopress/readme.txt b/projects/plugins/videopress/readme.txt index 4ba48cbeac7cf..959b18e9649ff 100644 --- a/projects/plugins/videopress/readme.txt +++ b/projects/plugins/videopress/readme.txt @@ -1,6 +1,6 @@ === Jetpack VideoPress === Contributors: automattic, retrofox, oskosk, thehenridev, renatoagds, lhkowalski, nunyvega, leogermani, cgastrell -Tags: video, video-hosting, video-player, cdn, vimeo, youtube, video-streaming, mobile-video, jetpack +Tags: video, video-hosting, video-player, cdn, video-streaming Requires at least: 6.3 Tested up to: 6.5 @@ -8,7 +8,7 @@ Stable tag: 1.5 Requires PHP: 7.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html -The finest video hosting for WordPress. Stunning-quality video with none of the hassle. Drag and drop videos through the WordPress editor and keep the focus on your content, not the ads. +The finest video hosting for WordPress. Drag and drop videos through the WordPress editor and keep the focus on your content, not the ads. == Description == From 91d38295c5a41c41350f739cf39de5405157f596 Mon Sep 17 00:00:00 2001 From: Tim Broddin Date: Wed, 3 Apr 2024 08:55:57 +0200 Subject: [PATCH 12/23] Add scheduled updates logs class (#36676) * Add Scheduled_Updated_Logs * Add Scheduled_Updated_Logs * Add file suppression * Fix test * Update baseline.php * Changelogger * Use option name from class * Use three existing statuses * Check for non-existant schedules --- .../scheduled-updates/.phan/baseline.php | 5 +- .../changelog/add-scheduled-updates-logs | 4 + .../packages/scheduled-updates/composer.json | 2 +- .../src/class-scheduled-updates-logs.php | 196 +++++++++++++ .../src/class-scheduled-updates.php | 2 +- .../php/class-scheduled-updates-logs-test.php | 261 ++++++++++++++++++ .../php/class-scheduled-updates-test.php | 2 + .../changelog/add-scheduled-updates-logs | 5 + .../changelog/add-scheduled-updates-logs#2 | 5 + .../plugins/mu-wpcom-plugin/composer.lock | 4 +- 10 files changed, 480 insertions(+), 6 deletions(-) create mode 100644 projects/packages/scheduled-updates/changelog/add-scheduled-updates-logs create mode 100644 projects/packages/scheduled-updates/src/class-scheduled-updates-logs.php create mode 100644 projects/packages/scheduled-updates/tests/php/class-scheduled-updates-logs-test.php create mode 100644 projects/plugins/mu-wpcom-plugin/changelog/add-scheduled-updates-logs create mode 100644 projects/plugins/mu-wpcom-plugin/changelog/add-scheduled-updates-logs#2 diff --git a/projects/packages/scheduled-updates/.phan/baseline.php b/projects/packages/scheduled-updates/.phan/baseline.php index 62a28cb7d245c..74832f049ae01 100644 --- a/projects/packages/scheduled-updates/.phan/baseline.php +++ b/projects/packages/scheduled-updates/.phan/baseline.php @@ -9,12 +9,12 @@ */ return [ // # Issue statistics: - // PhanUndeclaredProperty : 35+ occurrences + // PhanUndeclaredProperty : 40+ occurrences + // PhanCompatibleAccessMethodOnTraitDefinition : 2 occurrences // PhanPluginMixedKeyNoKey : 2 occurrences // PhanRedundantCondition : 2 occurrences // PhanTypeArraySuspiciousNullable : 2 occurrences // PhanUndeclaredClassMethod : 2 occurrences - // PhanCompatibleAccessMethodOnTraitDefinition : 1 occurrence // PhanNoopNew : 1 occurrence // PhanTypeMismatchArgumentProbablyReal : 1 occurrence // PhanTypeMismatchDimFetch : 1 occurrence @@ -24,6 +24,7 @@ 'src/class-scheduled-updates.php' => ['PhanRedundantCondition', 'PhanTypeMismatchArgumentProbablyReal', 'PhanTypeMismatchDimFetch', 'PhanUndeclaredClassMethod'], 'src/pluggable.php' => ['PhanTypeArraySuspiciousNullable'], 'src/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-update-schedules.php' => ['PhanPluginMixedKeyNoKey'], + 'tests/php/class-scheduled-updates-logs-test.php' => ['PhanCompatibleAccessMethodOnTraitDefinition', 'PhanUndeclaredProperty'], 'tests/php/class-scheduled-updates-test.php' => ['PhanCompatibleAccessMethodOnTraitDefinition', 'PhanUndeclaredProperty'], 'tests/php/class-wpcom-rest-api-v2-endpoint-update-schedules-test.php' => ['PhanNoopNew'], ], diff --git a/projects/packages/scheduled-updates/changelog/add-scheduled-updates-logs b/projects/packages/scheduled-updates/changelog/add-scheduled-updates-logs new file mode 100644 index 0000000000000..d9d53095c46c6 --- /dev/null +++ b/projects/packages/scheduled-updates/changelog/add-scheduled-updates-logs @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Add backend infrastructure to log scheduled update events diff --git a/projects/packages/scheduled-updates/composer.json b/projects/packages/scheduled-updates/composer.json index 10bbd92a4abd2..ada4677d92ff4 100644 --- a/projects/packages/scheduled-updates/composer.json +++ b/projects/packages/scheduled-updates/composer.json @@ -49,7 +49,7 @@ }, "autotagger": true, "branch-alias": { - "dev-trunk": "0.5.x-dev" + "dev-trunk": "0.6.x-dev" }, "textdomain": "jetpack-scheduled-updates", "version-constants": { diff --git a/projects/packages/scheduled-updates/src/class-scheduled-updates-logs.php b/projects/packages/scheduled-updates/src/class-scheduled-updates-logs.php new file mode 100644 index 0000000000000..93197fed9af63 --- /dev/null +++ b/projects/packages/scheduled-updates/src/class-scheduled-updates-logs.php @@ -0,0 +1,196 @@ + $timestamp, + 'action' => $action, + 'message' => $message, + 'context' => $context, + ); + + $logs = get_option( self::OPTION_NAME, array() ); + + if ( ! self::is_valid_schedule( $schedule_id ) ) { + return new WP_Error( 'invalid_schedule_id', 'Invalid schedule ID' ); + } + + if ( ! isset( $logs[ $schedule_id ] ) ) { + $logs[ $schedule_id ] = array(); + } + + $logs[ $schedule_id ][] = $log_entry; + + // Keep only the logs for the last MAX_RUNS_PER_SCHEDULE runs per schedule_id + $start_count = 0; + $last_two_runs = array(); + for ( $i = count( $logs[ $schedule_id ] ) - 1; $i >= 0; $i-- ) { + if ( self::PLUGIN_UPDATES_START === $logs[ $schedule_id ][ $i ]['action'] ) { + ++$start_count; + } + $last_two_runs[] = $logs[ $schedule_id ][ $i ]; + if ( self::MAX_RUNS_PER_SCHEDULE === $start_count ) { + break; + } + } + $last_two_runs = array_reverse( $last_two_runs ); + $logs[ $schedule_id ] = $last_two_runs; + + update_option( self::OPTION_NAME, $logs ); + } + + /** + * Retrieves the logs for a specific schedule_id or all logs if no schedule_id is provided. + * + * @param string|null $schedule_id Optional. The ID of the schedule. If not provided, all logs will be returned. + * + * @return array|WP_Error + * An array containing the logs, split by run. + * If a schedule_id is provided, the logs for that specific schedule are returned. + * If no schedule_id is provided, all logs are returned, with each schedule_id as a key in the array. + * Each run is an array of log entries, where each log entry is an associative array + * containing the following keys: + * - 'timestamp' (int): The Unix timestamp of the log entry. + * - 'action' (string): The action constant representing the event. + * - 'message' (string|null): The message associated with the event, if available. + * - 'context' (mixed|null): Additional context data associated with the event, if available. + */ + public static function get( $schedule_id = null ) { + $logs = get_option( self::OPTION_NAME, array() ); + + if ( null === $schedule_id ) { + // Return all logs if no schedule_id is provided + $all_logs = array(); + foreach ( $logs as $schedule_id => $schedule_logs ) { + $all_logs[ $schedule_id ] = self::split_logs_into_runs( $schedule_logs ); + } + return $all_logs; + } + + if ( ! self::is_valid_schedule( $schedule_id ) ) { + return new WP_Error( 'invalid_schedule_id', 'Invalid schedule ID' ); + } + + if ( ! isset( $logs[ $schedule_id ] ) ) { + return array(); + } + + $schedule_logs = $logs[ $schedule_id ]; + return self::split_logs_into_runs( $schedule_logs ); + } + + /** + * Clears the logs for a specific schedule_id or all logs if no schedule_id is provided. + * + * @param string|null $schedule_id Optional. The ID of the schedule. If not provided, all logs will be cleared. + * + * @return WP_Error|null + */ + public static function clear( string $schedule_id = null ) { + $logs = get_option( self::OPTION_NAME, array() ); + + if ( null === $schedule_id ) { + // Clear all logs if no schedule_id is provided + $logs = array(); + } else { + if ( ! self::is_valid_schedule( $schedule_id ) ) { + return new WP_Error( 'invalid_schedule_id', 'Invalid schedule ID' ); + } + + if ( isset( $logs[ $schedule_id ] ) ) { + // Clear the logs for the specific schedule_id + unset( $logs[ $schedule_id ] ); + } + } + + update_option( self::OPTION_NAME, $logs ); + } + + /** + * Splits the logs into runs based on the PLUGIN_UPDATES_START action. + * + * @param array $logs The logs to split into runs. + * + * @return array An array containing the logs split into runs. + */ + private static function split_logs_into_runs( $logs ) { + $runs = array(); + $current_run = array(); + + foreach ( $logs as $log_entry ) { + if ( self::PLUGIN_UPDATES_START === $log_entry['action'] ) { + if ( ! empty( $current_run ) ) { + $runs[] = $current_run; + } + $current_run = array(); + } + $current_run[] = $log_entry; + } + + if ( ! empty( $current_run ) ) { + $runs[] = $current_run; + } + + return $runs; + } + + /** + * Returns whether a schedule_id is valid. + * + * @param string $schedule_id The schedule id. + * @return bool + */ + private static function is_valid_schedule( $schedule_id ) { + $events = wp_get_scheduled_events( Scheduled_Updates::PLUGIN_CRON_HOOK ); + + if ( ! isset( $events[ $schedule_id ] ) ) { + return false; + } + + return true; + } +} diff --git a/projects/packages/scheduled-updates/src/class-scheduled-updates.php b/projects/packages/scheduled-updates/src/class-scheduled-updates.php index 2b56ab200b033..155e648c550fb 100644 --- a/projects/packages/scheduled-updates/src/class-scheduled-updates.php +++ b/projects/packages/scheduled-updates/src/class-scheduled-updates.php @@ -20,7 +20,7 @@ class Scheduled_Updates { * * @var string */ - const PACKAGE_VERSION = '0.5.3'; + const PACKAGE_VERSION = '0.6.0-alpha'; /** * The cron event hook for the scheduled plugins update. * diff --git a/projects/packages/scheduled-updates/tests/php/class-scheduled-updates-logs-test.php b/projects/packages/scheduled-updates/tests/php/class-scheduled-updates-logs-test.php new file mode 100644 index 0000000000000..90f26a4657e73 --- /dev/null +++ b/projects/packages/scheduled-updates/tests/php/class-scheduled-updates-logs-test.php @@ -0,0 +1,261 @@ +clear_all_users(); + Scheduled_Updates::init(); + + // Initialize the admin + $this->admin_id = wp_insert_user( + array( + 'user_login' => 'dumasdasdasmy_user', + 'user_pass' => 'dummy_pass', + 'role' => 'administrator', + ) + ); + wp_set_current_user( $this->admin_id ); + } + + /** + * Clean up after test + * + * @after + */ + protected function tear_down() { + delete_option( Scheduled_Updates_Logs::OPTION_NAME ); + + parent::tear_down_wordbless(); + } + + /** + * Test logging events and retrieving logs for a specific schedule ID. + * + * @covers ::log + * @covers ::get + */ + public function test_log_and_get_logs() { + $schedule_id = $this->create_schedule( 1 ); + + // Test logging events + Scheduled_Updates_Logs::log( $schedule_id, Scheduled_Updates_Logs::PLUGIN_UPDATES_START, 'Starting plugin updates' ); + Scheduled_Updates_Logs::log( $schedule_id, Scheduled_Updates_Logs::PLUGIN_UPDATE_SUCCESS, 'Plugin updated successfully', array( 'plugin' => 'test-plugin' ) ); + Scheduled_Updates_Logs::log( $schedule_id, Scheduled_Updates_Logs::PLUGIN_UPDATES_COMPLETE, 'Plugin updates completed' ); + + // Test retrieving logs + $logs = Scheduled_Updates_Logs::get( $schedule_id ); + + // Assert that logs are split into runs correctly + $this->assertCount( 1, $logs ); + $this->assertCount( 3, $logs[0] ); + + // Assert log entry values + $this->assertEquals( Scheduled_Updates_Logs::PLUGIN_UPDATES_START, $logs[0][0]['action'] ); + $this->assertEquals( 'Starting plugin updates', $logs[0][0]['message'] ); + $this->assertEquals( Scheduled_Updates_Logs::PLUGIN_UPDATE_SUCCESS, $logs[0][1]['action'] ); + $this->assertEquals( 'Plugin updated successfully', $logs[0][1]['message'] ); + $this->assertEquals( array( 'plugin' => 'test-plugin' ), $logs[0][1]['context'] ); + $this->assertEquals( Scheduled_Updates_Logs::PLUGIN_UPDATES_COMPLETE, $logs[0][2]['action'] ); + $this->assertEquals( 'Plugin updates completed', $logs[0][2]['message'] ); + } + + /** + * Test that only the last MAX_RUNS_PER_SCHEDULE runs are kept when logging events. + * + * @covers ::log + * @covers ::get + */ + public function test_max_runs_per_schedule() { + $schedule_id = $this->create_schedule( 1 ); + + // Log events for more than MAX_RUNS_PER_SCHEDULE + for ( $i = 1; $i <= Scheduled_Updates_Logs::MAX_RUNS_PER_SCHEDULE + 1; $i++ ) { + Scheduled_Updates_Logs::log( $schedule_id, Scheduled_Updates_Logs::PLUGIN_UPDATES_START, "Starting plugin updates (Run $i)" ); + Scheduled_Updates_Logs::log( $schedule_id, Scheduled_Updates_Logs::PLUGIN_UPDATES_COMPLETE, "Plugin updates completed (Run $i)" ); + } + + // Test retrieving logs + $logs = Scheduled_Updates_Logs::get( $schedule_id ); + + // Assert that only the last MAX_RUNS_PER_SCHEDULE runs are kept + $this->assertCount( Scheduled_Updates_Logs::MAX_RUNS_PER_SCHEDULE, $logs ); + $this->assertEquals( 'Starting plugin updates (Run 2)', $logs[0][0]['message'] ); + $this->assertEquals( 'Plugin updates completed (Run 2)', $logs[0][1]['message'] ); + $this->assertEquals( 'Starting plugin updates (Run 3)', $logs[1][0]['message'] ); + $this->assertEquals( 'Plugin updates completed (Run 3)', $logs[1][1]['message'] ); + } + + /** + * Test logging to a non-existent schedule ID. + * + * @covers ::get + */ + public function test_log_non_existent_schedule() { + $schedule_id = 'non_existent_schedule'; + + // Test retrieving logs for a non-existent schedule + $result = Scheduled_Updates_Logs::log( $schedule_id, Scheduled_Updates_Logs::PLUGIN_UPDATES_START, 'Starting plugin updates' ); + + // Assert that an empty array is returned + $this->assertInstanceOf( WP_Error::class, $result ); + } + + /** + * Test retrieving logs for a non-existent schedule ID. + * + * @covers ::get + */ + public function test_get_logs_non_existent_schedule() { + $schedule_id = 'non_existent_schedule'; + + // Test retrieving logs for a non-existent schedule + $logs = Scheduled_Updates_Logs::get( $schedule_id ); + + // Assert that an empty array is returned + $this->assertInstanceOf( WP_Error::class, $logs ); + } + + /** + * Test retrieving logs for multiple schedules. + * + * @covers ::log + * @covers ::get + */ + public function test_get_all_logs() { + $schedule_id_1 = $this->create_schedule( 1 ); + $schedule_id_2 = $this->create_schedule( 2 ); + + // Log events for multiple schedules + Scheduled_Updates_Logs::log( $schedule_id_1, Scheduled_Updates_Logs::PLUGIN_UPDATES_START, 'Starting plugin updates for schedule 1' ); + Scheduled_Updates_Logs::log( $schedule_id_1, Scheduled_Updates_Logs::PLUGIN_UPDATES_COMPLETE, 'Plugin updates completed for schedule 1' ); + Scheduled_Updates_Logs::log( $schedule_id_2, Scheduled_Updates_Logs::PLUGIN_UPDATES_START, 'Starting plugin updates for schedule 2' ); + Scheduled_Updates_Logs::log( $schedule_id_2, Scheduled_Updates_Logs::PLUGIN_UPDATES_COMPLETE, 'Plugin updates completed for schedule 2' ); + + // Test retrieving all logs + $all_logs = Scheduled_Updates_Logs::get(); + + // Assert that logs for both schedules are returned + $this->assertArrayHasKey( $schedule_id_1, $all_logs ); + $this->assertArrayHasKey( $schedule_id_2, $all_logs ); + $this->assertCount( 1, $all_logs[ $schedule_id_1 ] ); + $this->assertCount( 1, $all_logs[ $schedule_id_2 ] ); + $this->assertEquals( 'Starting plugin updates for schedule 1', $all_logs[ $schedule_id_1 ][0][0]['message'] ); + $this->assertEquals( 'Plugin updates completed for schedule 1', $all_logs[ $schedule_id_1 ][0][1]['message'] ); + $this->assertEquals( 'Starting plugin updates for schedule 2', $all_logs[ $schedule_id_2 ][0][0]['message'] ); + $this->assertEquals( 'Plugin updates completed for schedule 2', $all_logs[ $schedule_id_2 ][0][1]['message'] ); + } + + /** + * Test clearing logs for a specific schedule ID and clearing all logs. + * + * @covers ::log + * @covers ::clear + * @covers ::get + */ + public function test_clear_logs() { + $schedule_id_1 = $this->create_schedule( 1 ); + $schedule_id_2 = $this->create_schedule( 2 ); + + // Log events for multiple schedules + Scheduled_Updates_Logs::log( $schedule_id_1, Scheduled_Updates_Logs::PLUGIN_UPDATES_START, 'Starting plugin updates for schedule 1' ); + Scheduled_Updates_Logs::log( $schedule_id_2, Scheduled_Updates_Logs::PLUGIN_UPDATES_START, 'Starting plugin updates for schedule 2' ); + + // Clear logs for a specific schedule + Scheduled_Updates_Logs::clear( $schedule_id_1 ); + + // Test retrieving logs after clearing + $logs_schedule_1 = Scheduled_Updates_Logs::get( $schedule_id_1 ); + $logs_schedule_2 = Scheduled_Updates_Logs::get( $schedule_id_2 ); + + // Assert that logs for the cleared schedule are empty + $this->assertEmpty( $logs_schedule_1 ); + // Assert that logs for the other schedule are still present + $this->assertNotEmpty( $logs_schedule_2 ); + + // Clear all logs + Scheduled_Updates_Logs::clear(); + + // Test retrieving all logs after clearing + $all_logs = Scheduled_Updates_Logs::get(); + + // Assert that all logs are empty + $this->assertEmpty( $all_logs ); + } + + /** + * Test clearing logs for a non-existent schedule ID. + * + * @covers ::get + */ + public function test_clear_logs_non_existent_schedule() { + $schedule_id = 'non_existent_schedule'; + + // Test retrieving logs for a non-existent schedule + $logs = Scheduled_Updates_Logs::clear( $schedule_id ); + + // Assert that an empty array is returned + $this->assertInstanceOf( WP_Error::class, $logs ); + } + + /** + * Create schedule + * + * @param int $i Schedule index. + */ + private function create_schedule( $i = 0 ) { + $request = new \WP_REST_Request( 'POST', '/wpcom/v2/update-schedules' ); + $scheduled_plugins = array( 'test/test' . $i . '.php' ); + $request->set_body_params( + array( + 'plugins' => $scheduled_plugins, + 'schedule' => array( + 'timestamp' => strtotime( "next Monday {$i}:00" ), + 'interval' => 'weekly', + ), + ) + ); + + $result = rest_do_request( $request ); + return $result->get_data(); + } +} diff --git a/projects/packages/scheduled-updates/tests/php/class-scheduled-updates-test.php b/projects/packages/scheduled-updates/tests/php/class-scheduled-updates-test.php index ced9d0f49c857..c3612cf5d7434 100644 --- a/projects/packages/scheduled-updates/tests/php/class-scheduled-updates-test.php +++ b/projects/packages/scheduled-updates/tests/php/class-scheduled-updates-test.php @@ -43,6 +43,7 @@ public static function set_up_before_class() { protected function set_up() { parent::set_up_wordbless(); \WorDBless\Users::init()->clear_all_users(); + Scheduled_Updates::init(); // Initialize the WordPress filesystem variable. global $wp_filesystem; @@ -220,6 +221,7 @@ public function test_event_is_deleted_on_plugin_deletion() { $this->assertSame( 200, $result->get_status() ); $this->assertCount( 1, wp_get_scheduled_events( Scheduled_Updates::PLUGIN_CRON_HOOK ) ); $this->assertTrue( delete_plugins( array( $plugins[0] ) ) ); + $this->assertCount( 0, wp_get_scheduled_events( Scheduled_Updates::PLUGIN_CRON_HOOK ) ); } diff --git a/projects/plugins/mu-wpcom-plugin/changelog/add-scheduled-updates-logs b/projects/plugins/mu-wpcom-plugin/changelog/add-scheduled-updates-logs new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/mu-wpcom-plugin/changelog/add-scheduled-updates-logs @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/mu-wpcom-plugin/changelog/add-scheduled-updates-logs#2 b/projects/plugins/mu-wpcom-plugin/changelog/add-scheduled-updates-logs#2 new file mode 100644 index 0000000000000..9aa70e3ec1f75 --- /dev/null +++ b/projects/plugins/mu-wpcom-plugin/changelog/add-scheduled-updates-logs#2 @@ -0,0 +1,5 @@ +Significance: patch +Type: changed +Comment: Updated composer.lock. + + diff --git a/projects/plugins/mu-wpcom-plugin/composer.lock b/projects/plugins/mu-wpcom-plugin/composer.lock index 3c727486d59fb..b6458de076c5b 100644 --- a/projects/plugins/mu-wpcom-plugin/composer.lock +++ b/projects/plugins/mu-wpcom-plugin/composer.lock @@ -198,7 +198,7 @@ "dist": { "type": "path", "url": "../../packages/scheduled-updates", - "reference": "2704973c5e719327c92e4889ca11fac27d0a861d" + "reference": "2a989d1848db4a9ad658ecb04e93a7278a905b23" }, "require": { "php": ">=7.0" @@ -221,7 +221,7 @@ }, "autotagger": true, "branch-alias": { - "dev-trunk": "0.5.x-dev" + "dev-trunk": "0.6.x-dev" }, "textdomain": "jetpack-scheduled-updates", "version-constants": { From ec308526fa578796ebe79519192094f162f5a579 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Wed, 3 Apr 2024 08:57:58 +0200 Subject: [PATCH 13/23] SSO: disable user invite system on Multisite (#36690) Fixes #36682 --- projects/plugins/jetpack/changelog/update-sso-no-multisite | 4 ++++ projects/plugins/jetpack/modules/sso.php | 1 + 2 files changed, 5 insertions(+) create mode 100644 projects/plugins/jetpack/changelog/update-sso-no-multisite diff --git a/projects/plugins/jetpack/changelog/update-sso-no-multisite b/projects/plugins/jetpack/changelog/update-sso-no-multisite new file mode 100644 index 0000000000000..9ee391a7c74ce --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-sso-no-multisite @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Secure Sign-On: disable the WordPress.com invitation setup on Multisite. diff --git a/projects/plugins/jetpack/modules/sso.php b/projects/plugins/jetpack/modules/sso.php index c41aab2ee51cf..b459fc2a0abc0 100644 --- a/projects/plugins/jetpack/modules/sso.php +++ b/projects/plugins/jetpack/modules/sso.php @@ -97,6 +97,7 @@ private function __construct() { */ if ( Jetpack_SSO_Helpers::is_user_connected() && + ! is_multisite() && /** * Toggle the ability to invite new users to create a WordPress.com account. * From b1c5f4b19dbb9b032bfe743a9b09e16ef429b702 Mon Sep 17 00:00:00 2001 From: Kosta Date: Wed, 3 Apr 2024 09:18:58 +0200 Subject: [PATCH 14/23] Fix untranslated sharing label (#36695) --- .../jetpack/changelog/fix-translation-issues | 4 + .../blocks/subscriptions/subscriptions.php | 84 ++++++++++++++++++- .../modules/sharedaddy/sharing-service.php | 2 +- 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/fix-translation-issues diff --git a/projects/plugins/jetpack/changelog/fix-translation-issues b/projects/plugins/jetpack/changelog/fix-translation-issues new file mode 100644 index 0000000000000..52d5c014cf966 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-translation-issues @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Fix translation issues for default attributes diff --git a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php index 32c29b156b593..0b985dae81337 100644 --- a/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php +++ b/projects/plugins/jetpack/extensions/blocks/subscriptions/subscriptions.php @@ -60,6 +60,88 @@ function register_block() { ), 'align' => array( 'wide', 'full' ), ), + 'attributes' => array( + 'subscribePlaceholder' => array( + 'type' => 'string', + 'default' => __( 'Type your email…', 'jetpack' ), + ), + 'showSubscribersTotal' => array( + 'type' => 'boolean', + 'default' => false, + ), + 'includeSocialFollowers' => array( + 'type' => 'boolean', + ), + 'buttonOnNewLine' => array( + 'type' => 'boolean', + 'default' => false, + ), + 'buttonWidth' => array( + 'type' => 'string', + ), + 'submitButtonText' => array( + 'type' => 'string', + 'default' => __( 'Subscribe', 'jetpack' ), + ), + 'emailFieldBackgroundColor' => array( + 'type' => 'string', + ), + 'customEmailFieldBackgroundColor' => array( + 'type' => 'string', + ), + 'emailFieldGradient' => array( + 'type' => 'string', + ), + 'customEmailFieldGradient' => array( + 'type' => 'string', + ), + 'buttonBackgroundColor' => array( + 'type' => 'string', + ), + 'customButtonBackgroundColor' => array( + 'type' => 'string', + ), + 'buttonGradient' => array( + 'type' => 'string', + ), + 'customButtonGradient' => array( + 'type' => 'string', + ), + 'textColor' => array( + 'type' => 'string', + ), + 'customTextColor' => array( + 'type' => 'string', + ), + 'fontSize' => array( + 'type' => 'string', + ), + 'customFontSize' => array( + 'type' => 'string', + ), + 'borderRadius' => array( + 'type' => 'number', + ), + 'borderWeight' => array( + 'type' => 'number', + ), + 'borderColor' => array( + 'type' => 'string', + ), + 'customBorderColor' => array( + 'type' => 'string', + ), + 'padding' => array( + 'type' => 'number', + ), + 'spacing' => array( + 'type' => 'number', + ), + 'successMessage' => array( + 'type' => 'string', + 'default' => __( 'Success! An email was just sent to confirm your subscription. Please find the email now and click \'Confirm Follow\' to start subscribing.', 'jetpack' ), + ), + ), ) ); } @@ -764,7 +846,7 @@ class="screen-reader-text" esc_attr( $subscribe_field_id ), ( ! empty( $data['subscribe_email'] ) ? 'disabled title="' . esc_attr__( "You're logged in with this email", 'jetpack' ) . '"' - : '' + : 'title="' . esc_attr__( 'Please fill in this field.', 'jetpack' ) . '"' ) ); ?> diff --git a/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php b/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php index 1e2b4a8a30de0..b190974c77311 100644 --- a/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php +++ b/projects/plugins/jetpack/modules/sharedaddy/sharing-service.php @@ -501,7 +501,7 @@ public function get_global_options() { } } - if ( false === $this->global['sharing_label'] ) { + if ( false === $this->global['sharing_label'] || $this->global['sharing_label'] === 'Share this:' ) { $this->global['sharing_label'] = $this->default_sharing_label; } From 010976bc4f7120c2c7194f2ce9cd6225df8efabb Mon Sep 17 00:00:00 2001 From: Candy Tsai Date: Wed, 3 Apr 2024 16:45:43 +0800 Subject: [PATCH 15/23] Update Odyssey Stats default name and slug in Admin Menu (#36689) * Update Odyssey Stats name and slug in Admin Menu * changelog * version bump --- .../stats-admin/changelog/update-odyssey-stats-menu | 4 ++++ projects/packages/stats-admin/package.json | 2 +- projects/packages/stats-admin/src/class-dashboard.php | 6 +++--- projects/packages/stats-admin/src/class-main.php | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 projects/packages/stats-admin/changelog/update-odyssey-stats-menu diff --git a/projects/packages/stats-admin/changelog/update-odyssey-stats-menu b/projects/packages/stats-admin/changelog/update-odyssey-stats-menu new file mode 100644 index 0000000000000..185cf20c2d568 --- /dev/null +++ b/projects/packages/stats-admin/changelog/update-odyssey-stats-menu @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Change Odyssey Stats default admin menu name and slug for Simple Classic. diff --git a/projects/packages/stats-admin/package.json b/projects/packages/stats-admin/package.json index cdd58afee0b60..549de5d9fd3ee 100644 --- a/projects/packages/stats-admin/package.json +++ b/projects/packages/stats-admin/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-stats-admin", - "version": "0.18.0", + "version": "0.18.1-alpha", "description": "Stats Dashboard", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/stats-admin/#readme", "bugs": { diff --git a/projects/packages/stats-admin/src/class-dashboard.php b/projects/packages/stats-admin/src/class-dashboard.php index 46f79a6d85637..ef2a8332f99d9 100644 --- a/projects/packages/stats-admin/src/class-dashboard.php +++ b/projects/packages/stats-admin/src/class-dashboard.php @@ -56,10 +56,10 @@ public function init_hooks() { */ public function add_wp_admin_submenu() { $page_suffix = Admin_Menu::add_menu( - __( 'Stats App', 'jetpack-stats-admin' ), - _x( 'Stats App', 'product name shown in menu', 'jetpack-stats-admin' ), + __( 'Stats', 'jetpack-stats-admin' ), + _x( 'Stats', 'product name shown in menu', 'jetpack-stats-admin' ), 'manage_options', - 'jetpack-stats-app', + 'stats', array( $this, 'render' ) ); diff --git a/projects/packages/stats-admin/src/class-main.php b/projects/packages/stats-admin/src/class-main.php index 4589b8236c4d9..56744156d31b0 100644 --- a/projects/packages/stats-admin/src/class-main.php +++ b/projects/packages/stats-admin/src/class-main.php @@ -22,7 +22,7 @@ class Main { /** * Stats version. */ - const VERSION = '0.18.0'; + const VERSION = '0.18.1-alpha'; /** * Singleton Main instance. From 6fc169d21f14a920fed6eb05b70f433bfde73ae1 Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Wed, 3 Apr 2024 14:22:13 +0530 Subject: [PATCH 16/23] Social Notes: Add options and UI for link formatting (#36671) * Add options and UI for link formatting * Add changelog * Fix versions * Add option to sync * Add changelog * Update versions * Update option name * Set fields to be always controlled * Update test_class.jetpack-sync-options.php * Add changelog * Fix state update on API call failure * Improve naming for parenthical link format * Use dropdown for link format instead of toggles * Update docs link * Restore toggle color --- .../add-options-and-ui-for-link-formatting | 4 ++ .../publicize-components/package.json | 2 +- .../actions/social-notes-settings.js | 32 ++++++++++ .../selectors/jetpack-settings.js | 1 + .../add-options-and-ui-for-link-formatting | 4 ++ projects/packages/sync/src/class-defaults.php | 1 + .../add-options-and-ui-for-link-formatting | 5 ++ .../sync/test_class.jetpack-sync-options.php | 1 + .../add-options-and-ui-for-link-formatting | 4 ++ .../social/src/class-jetpack-social.php | 5 +- projects/plugins/social/src/class-note.php | 31 +++++++++- .../src/class-rest-settings-controller.php | 33 +++++++++- .../components/social-notes-toggle/index.tsx | 62 +++++++++++++++++-- .../social-notes-toggle/styles.module.scss | 31 +++++++++- 14 files changed, 203 insertions(+), 13 deletions(-) create mode 100644 projects/js-packages/publicize-components/changelog/add-options-and-ui-for-link-formatting create mode 100644 projects/packages/sync/changelog/add-options-and-ui-for-link-formatting create mode 100644 projects/plugins/jetpack/changelog/add-options-and-ui-for-link-formatting create mode 100644 projects/plugins/social/changelog/add-options-and-ui-for-link-formatting diff --git a/projects/js-packages/publicize-components/changelog/add-options-and-ui-for-link-formatting b/projects/js-packages/publicize-components/changelog/add-options-and-ui-for-link-formatting new file mode 100644 index 0000000000000..0cb966ded0a6a --- /dev/null +++ b/projects/js-packages/publicize-components/changelog/add-options-and-ui-for-link-formatting @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Added options and UI for link formatting diff --git a/projects/js-packages/publicize-components/package.json b/projects/js-packages/publicize-components/package.json index a0698d78f88e1..415a122568b1c 100644 --- a/projects/js-packages/publicize-components/package.json +++ b/projects/js-packages/publicize-components/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-publicize-components", - "version": "0.48.5", + "version": "0.48.6-alpha", "description": "A library of JS components required by the Publicize editor plugin", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/publicize-components/#readme", "bugs": { diff --git a/projects/js-packages/publicize-components/src/social-store/actions/social-notes-settings.js b/projects/js-packages/publicize-components/src/social-store/actions/social-notes-settings.js index 17d6826089ddb..f45f03a23a10f 100644 --- a/projects/js-packages/publicize-components/src/social-store/actions/social-notes-settings.js +++ b/projects/js-packages/publicize-components/src/social-store/actions/social-notes-settings.js @@ -30,6 +30,28 @@ export function* updateSocialNotesSettings( settings ) { } } +/** + * Yield actions to update settings + * + * @param {object} config - config to update + * @yields {object} - an action object. + * @returns {object} - an action object. + */ +export function* updateSocialNotesConfig( config ) { + const prevConfig = select( SOCIAL_STORE_ID ).getSocialNotesConfig(); + const newConfig = { ...prevConfig, ...config }; + try { + yield setJetpackSettings( { social_notes_config: newConfig } ); + yield updateJetpackSettingsControl( { social_notes_config: config } ); + const updatedSettings = yield fetchJetpackSettings(); + yield setJetpackSettings( updatedSettings ); + return true; + } catch ( e ) { + yield setJetpackSettings( { social_notes_config: prevConfig } ); + return false; + } +} + /** * Yield actions to refresh settings * @@ -67,7 +89,17 @@ export function setUpdatingSocialNotesSettingsDone() { return setJetpackSettings( { social_notes_is_updating: false } ); } +/** + * Set state updating action + * + * @returns {object} - an action object. + */ +export function setUpdatingSocialNotesConfig() { + return setJetpackSettings( { social_notes_config_is_updating: true } ); +} + export default { updateSocialNotesSettings, + updateSocialNotesConfig, refreshSocialNotesSettings, }; diff --git a/projects/js-packages/publicize-components/src/social-store/selectors/jetpack-settings.js b/projects/js-packages/publicize-components/src/social-store/selectors/jetpack-settings.js index 829c9ca344e44..66fd71d5add49 100644 --- a/projects/js-packages/publicize-components/src/social-store/selectors/jetpack-settings.js +++ b/projects/js-packages/publicize-components/src/social-store/selectors/jetpack-settings.js @@ -8,6 +8,7 @@ const jetpackSettingSelectors = { getDismissedNotices: state => state.jetpackSettings?.dismissedNotices, isSocialNotesEnabled: state => state.jetpackSettings?.social_notes_enabled, isSocialNotesSettingsUpdating: state => state.jetpackSettings?.social_notes_is_updating, + getSocialNotesConfig: state => state.jetpackSettings?.social_notes_config ?? {}, }; export default jetpackSettingSelectors; diff --git a/projects/packages/sync/changelog/add-options-and-ui-for-link-formatting b/projects/packages/sync/changelog/add-options-and-ui-for-link-formatting new file mode 100644 index 0000000000000..ede5d0b0ec9dc --- /dev/null +++ b/projects/packages/sync/changelog/add-options-and-ui-for-link-formatting @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Added social_notes_config option to sync diff --git a/projects/packages/sync/src/class-defaults.php b/projects/packages/sync/src/class-defaults.php index 2654dbd7e0898..8f7d480f184e6 100644 --- a/projects/packages/sync/src/class-defaults.php +++ b/projects/packages/sync/src/class-defaults.php @@ -88,6 +88,7 @@ class Defaults { 'jetpack_protect_key', 'jetpack_publicize_options', 'jetpack_relatedposts', + 'jetpack_social_notes_config', 'jetpack_social_settings', 'jetpack_social_autoconvert_images', 'jetpack_sso_match_by_email', diff --git a/projects/plugins/jetpack/changelog/add-options-and-ui-for-link-formatting b/projects/plugins/jetpack/changelog/add-options-and-ui-for-link-formatting new file mode 100644 index 0000000000000..ecd343e033a45 --- /dev/null +++ b/projects/plugins/jetpack/changelog/add-options-and-ui-for-link-formatting @@ -0,0 +1,5 @@ +Significance: patch +Type: other +Comment: Added a test for a synced option + + diff --git a/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php b/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php index f9e5752fe4942..df3cc4dc4fe4d 100644 --- a/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php +++ b/projects/plugins/jetpack/tests/php/sync/test_class.jetpack-sync-options.php @@ -220,6 +220,7 @@ public function test_sync_default_options() { 'jetpack_excluded_extensions' => 'pineapple', 'jetpack-memberships-has-connected-account' => true, 'jetpack_publicize_options' => array(), + 'jetpack_social_notes_config' => array(), 'jetpack_connection_active_plugins' => array( 'jetpack' ), 'jetpack_social_settings' => array( 'image' => true ), 'jetpack_social_autoconvert_images' => array( 'enabled' => true ), diff --git a/projects/plugins/social/changelog/add-options-and-ui-for-link-formatting b/projects/plugins/social/changelog/add-options-and-ui-for-link-formatting new file mode 100644 index 0000000000000..0cb966ded0a6a --- /dev/null +++ b/projects/plugins/social/changelog/add-options-and-ui-for-link-formatting @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Added options and UI for link formatting diff --git a/projects/plugins/social/src/class-jetpack-social.php b/projects/plugins/social/src/class-jetpack-social.php index 47691a8c97241..6d2fe0e45f0f5 100644 --- a/projects/plugins/social/src/class-jetpack-social.php +++ b/projects/plugins/social/src/class-jetpack-social.php @@ -238,6 +238,8 @@ public function initial_state() { $jetpack_social_settings = new Automattic\Jetpack\Publicize\Jetpack_Social_Settings\Settings(); $settings = $jetpack_social_settings->get_settings( true ); + $note = new Automattic\Jetpack\Social\Note(); + $state = array_merge( $state, array( @@ -248,7 +250,8 @@ public function initial_state() { 'isEnhancedPublishingEnabled' => $publicize->has_enhanced_publishing_feature(), 'dismissedNotices' => Dismissed_Notices::get_dismissed_notices(), 'supportedAdditionalConnections' => $publicize->get_supported_additional_connections(), - 'social_notes_enabled' => ( new Automattic\Jetpack\Social\Note() )->enabled(), + 'social_notes_enabled' => $note->enabled(), + 'social_notes_config' => $note->get_config(), ), 'connectionData' => array( 'connections' => $publicize->get_all_connections_for_user(), // TODO: Sanitize the array diff --git a/projects/plugins/social/src/class-note.php b/projects/plugins/social/src/class-note.php index e8e6260a09986..71d71b520d327 100644 --- a/projects/plugins/social/src/class-note.php +++ b/projects/plugins/social/src/class-note.php @@ -12,6 +12,7 @@ */ class Note { const JETPACK_SOCIAL_NOTE_CPT = 'jetpack-social-note'; + const JETPACK_SOCIAL_NOTES_CONFIG = 'jetpack_social_notes_config'; const FLUSH_REWRITE_RULES_FLUSHED = 'jetpack_social_rewrite_rules_flushed'; /** @@ -136,7 +137,7 @@ public function register_cpt() { */ public function restrict_blocks_for_social_note( $allowed_blocks, $post ) { if ( 'jetpack-social-note' === $post->post_type ) { - // Only allow paragraph block + // Only allow paragraph block. $allowed_blocks = array( 'core/paragraph', ); @@ -176,6 +177,32 @@ public function set_enabled( $enabled ) { delete_option( self::FLUSH_REWRITE_RULES_FLUSHED ); } + /** + * Get the social notes config. + * + * @return array The social notes config. + */ + public function get_config() { + return get_option( + self::JETPACK_SOCIAL_NOTES_CONFIG, + // Append link by default. + array( + 'append_link' => true, + ) + ); + } + + /** + * Update social notes config + * + * @param array $config The config to update. + */ + public function update_config( $config ) { + $old_config = get_option( self::JETPACK_SOCIAL_NOTES_CONFIG, array() ); + $new_config = array_merge( $old_config, $config ); + update_option( self::JETPACK_SOCIAL_NOTES_CONFIG, $new_config ); + } + /** * Use the_title hook so we show the social note's exceprt in the post list view. * @@ -187,7 +214,7 @@ public function override_empty_title( $title, $post_id ) { return wp_trim_words( get_the_excerpt(), 10 ); } - // Return the original title for other cases + // Return the original title for other cases. return $title; } } diff --git a/projects/plugins/social/src/class-rest-settings-controller.php b/projects/plugins/social/src/class-rest-settings-controller.php index a91c121a46161..c95918a08a269 100644 --- a/projects/plugins/social/src/class-rest-settings-controller.php +++ b/projects/plugins/social/src/class-rest-settings-controller.php @@ -110,8 +110,14 @@ public function get_item( $request ) { $data['show_pricing_page'] = Jetpack_Social::should_show_pricing_page(); } + $note = new Note(); + if ( rest_is_field_included( 'social_notes_enabled', $fields ) ) { - $data['social_notes_enabled'] = ( new Note() )->enabled(); + $data['social_notes_enabled'] = $note->enabled(); + } + + if ( rest_is_field_included( 'social_notes_config', $fields ) ) { + $data['social_notes_config'] = $note->get_config(); } return $this->prepare_item_for_response( $data, $request ); @@ -126,6 +132,8 @@ public function update_item( $request ) { $params = $request->get_params(); $settings = $this->get_endpoint_args_for_item_schema( $request->get_method() ); + $note = new Note(); + foreach ( array_keys( $settings ) as $name ) { if ( ! array_key_exists( $name, $params ) ) { continue; @@ -142,7 +150,10 @@ public function update_item( $request ) { update_option( Jetpack_Social::JETPACK_SOCIAL_SHOW_PRICING_PAGE_OPTION, (int) $params[ $name ] ); break; case 'social_notes_enabled': - ( new Note() )->set_enabled( (bool) $params[ $name ] ); + $note->set_enabled( (bool) $params[ $name ] ); + break; + case 'social_notes_config': + $note->update_config( $params[ $name ] ); break; } } @@ -226,6 +237,24 @@ public function get_item_schema() { 'type' => 'boolean', 'context' => array( 'view', 'edit' ), ), + 'social_notes_config' => array( + 'description' => __( 'The social notes configuration', 'jetpack-social' ), + 'type' => 'object', + 'context' => array( 'view', 'edit' ), + 'properties' => array( + 'append_link' => array( + 'description' => __( 'Whether to append the post link when sharing the note.', 'jetpack-social' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit' ), + ), + 'link_format' => array( + 'description' => __( 'Link format', 'jetpack-social' ), + 'type' => 'string', + 'enum' => array( 'full_url', 'shortlink', 'permashortcitation' ), + 'context' => array( 'view', 'edit' ), + ), + ), + ), ), ); return $this->add_additional_fields_schema( $schema ); diff --git a/projects/plugins/social/src/js/components/social-notes-toggle/index.tsx b/projects/plugins/social/src/js/components/social-notes-toggle/index.tsx index f2475a6142495..682b47a881d9f 100644 --- a/projects/plugins/social/src/js/components/social-notes-toggle/index.tsx +++ b/projects/plugins/social/src/js/components/social-notes-toggle/index.tsx @@ -1,11 +1,11 @@ import { Text } from '@automattic/jetpack-components'; -import { SOCIAL_STORE_ID } from '@automattic/jetpack-publicize-components'; -import { useSelect, useDispatch } from '@wordpress/data'; +import { store as socialStore } from '@automattic/jetpack-publicize-components'; +import { ExternalLink, SelectControl, ToggleControl } from '@wordpress/components'; +import { useDispatch, useSelect } from '@wordpress/data'; import { useCallback } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import React, { useState } from 'react'; import ToggleSection from '../toggle-section'; -import { SocialStoreSelectors } from '../types/types'; import styles from './styles.module.scss'; type SocialNotesToggleProps = { @@ -16,10 +16,11 @@ type SocialNotesToggleProps = { }; const SocialNotesToggle: React.FC< SocialNotesToggleProps > = ( { disabled } ) => { - const { isEnabled } = useSelect( select => { - const store = select( SOCIAL_STORE_ID ) as SocialStoreSelectors; + const { isEnabled, notesConfig } = useSelect( select => { + const store = select( socialStore ); return { isEnabled: store.isSocialNotesEnabled(), + notesConfig: store.getSocialNotesConfig(), // Temporarily we disable forever after action to wait for the page to reload. // isUpdating: store.isSocialNotesSettingsUpdating(), }; @@ -27,7 +28,8 @@ const SocialNotesToggle: React.FC< SocialNotesToggleProps > = ( { disabled } ) = const [ isUpdating, setIsUpdating ] = useState( false ); - const updateOptions = useDispatch( SOCIAL_STORE_ID ).updateSocialNotesSettings; + const { updateSocialNotesSettings: updateOptions, updateSocialNotesConfig } = + useDispatch( socialStore ); const toggleStatus = useCallback( () => { const newOption = { @@ -44,6 +46,22 @@ const SocialNotesToggle: React.FC< SocialNotesToggleProps > = ( { disabled } ) = } ); }, [ isEnabled, updateOptions ] ); + const onToggleAppendLink = useCallback( + ( append_link: boolean ) => { + updateSocialNotesConfig( { append_link } ); + }, + [ updateSocialNotesConfig ] + ); + + const onChangeLinkFormat = useCallback( + ( link_format: string ) => { + updateSocialNotesConfig( { link_format } ); + }, + [ updateSocialNotesConfig ] + ); + + const appendLink = notesConfig.append_link ?? true; + return ( = ( { disabled } ) = 'jetpack-social' ) } + { isEnabled && ! isUpdating ? ( +
+ + { appendLink ? ( + + { __( 'Format of the link to use when sharing a note.', 'jetpack-social' ) } +   + + { __( 'Learn more', 'jetpack-social' ) } + + + } + /> + ) : null } +
+ ) : null }
); }; diff --git a/projects/plugins/social/src/js/components/social-notes-toggle/styles.module.scss b/projects/plugins/social/src/js/components/social-notes-toggle/styles.module.scss index 3c932a1c0aa9c..681ba6d057691 100644 --- a/projects/plugins/social/src/js/components/social-notes-toggle/styles.module.scss +++ b/projects/plugins/social/src/js/components/social-notes-toggle/styles.module.scss @@ -5,7 +5,36 @@ color: inherit; } - @media ( min-width: 600px ) { + @media (min-width: 600px) { grid-column: 2; } } + +.notes-options-wrapper { + display: flex; + flex-direction: column; + gap: 1rem; + margin-top: calc(var(--spacing-base) * 2); + grid-column: span 2; + + @media (min-width: 600px) { + grid-column: 2; + } + + :global { + .components-base-control { + &__field { + --wp-admin-theme-color: var(--jp-green-40); + } + + label.components-input-control__label { + text-transform: none; + font-weight: inherit; + font-size: inherit; + } + .components-input-control__container { + max-width: max-content; + } + } + } +} From 1ff896c62e0cafa3d40bce8ca5f075c04a58641b Mon Sep 17 00:00:00 2001 From: Manzoor Wani Date: Wed, 3 Apr 2024 14:35:44 +0530 Subject: [PATCH 17/23] Social notes | Fix i18n for link format options (#36715) * Social notes | Fix i18n for link format options * Add changelog --- .../fix-social-notes-i18n-for-link-format-options | 5 +++++ .../src/js/components/social-notes-toggle/index.tsx | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 projects/plugins/social/changelog/fix-social-notes-i18n-for-link-format-options diff --git a/projects/plugins/social/changelog/fix-social-notes-i18n-for-link-format-options b/projects/plugins/social/changelog/fix-social-notes-i18n-for-link-format-options new file mode 100644 index 0000000000000..c0df895a36e2a --- /dev/null +++ b/projects/plugins/social/changelog/fix-social-notes-i18n-for-link-format-options @@ -0,0 +1,5 @@ +Significance: patch +Type: fixed +Comment: Fix for the previous PR + + diff --git a/projects/plugins/social/src/js/components/social-notes-toggle/index.tsx b/projects/plugins/social/src/js/components/social-notes-toggle/index.tsx index 682b47a881d9f..9c856f8198aea 100644 --- a/projects/plugins/social/src/js/components/social-notes-toggle/index.tsx +++ b/projects/plugins/social/src/js/components/social-notes-toggle/index.tsx @@ -91,9 +91,12 @@ const SocialNotesToggle: React.FC< SocialNotesToggleProps > = ( { disabled } ) = value={ notesConfig.link_format ?? 'full_url' } onChange={ onChangeLinkFormat } options={ [ - { label: 'Full URL', value: 'full_url' }, - { label: 'Shortlink', value: 'shortlink' }, - { label: 'Permashortcitation', value: 'permashortcitation' }, + { label: __( 'Full URL', 'jetpack-social' ), value: 'full_url' }, + { label: __( 'Shortlink', 'jetpack-social' ), value: 'shortlink' }, + { + label: __( 'Permashortcitation', 'jetpack-social' ), + value: 'permashortcitation', + }, ] } help={ From d0cbc0b123db95226c1125ae46a88f40f8a09bb7 Mon Sep 17 00:00:00 2001 From: Michalis Despotopoulos Date: Wed, 3 Apr 2024 12:03:21 +0100 Subject: [PATCH 18/23] Extract browser and platform from user agent (#36568) * Add get_browser capability * changelog * Remove union types for backwards compatibility * Add get desktop platform method * Update Add get_browser capability for device stats * Browser and platform details to methods --------- Co-authored-by: Michalis Despotopoulos --- ...dd get_browser capability for device stats | 4 + .../src/class-device-detection.php | 2 + .../src/class-user-agent-info.php | 188 ++++++++++++++++-- .../tests/php/test_DeviceDetection.php | 84 ++++++++ 4 files changed, 265 insertions(+), 13 deletions(-) create mode 100644 projects/packages/device-detection/changelog/Add get_browser capability for device stats diff --git a/projects/packages/device-detection/changelog/Add get_browser capability for device stats b/projects/packages/device-detection/changelog/Add get_browser capability for device stats new file mode 100644 index 0000000000000..c52e5cf94307c --- /dev/null +++ b/projects/packages/device-detection/changelog/Add get_browser capability for device stats @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Added functionality for extracting the browser and desktop platform from a user agent diff --git a/projects/packages/device-detection/src/class-device-detection.php b/projects/packages/device-detection/src/class-device-detection.php index 14fb070954cfb..767a552ccbee6 100644 --- a/projects/packages/device-detection/src/class-device-detection.php +++ b/projects/packages/device-detection/src/class-device-detection.php @@ -49,6 +49,8 @@ public static function get_info( $ua = '' ) { 'is_smartphone' => self::is_mobile( 'smart', false, $ua_info ), 'is_tablet' => $ua_info->is_tablet(), 'platform' => $ua_info->get_platform(), + 'desktop_platform' => $ua_info->get_desktop_platform(), + 'browser' => $ua_info->get_browser(), ); $info['is_handheld'] = $info['is_phone'] || $info['is_tablet']; diff --git a/projects/packages/device-detection/src/class-user-agent-info.php b/projects/packages/device-detection/src/class-user-agent-info.php index 416fcd0a26c9c..c6e5a41e3f70f 100644 --- a/projects/packages/device-detection/src/class-user-agent-info.php +++ b/projects/packages/device-detection/src/class-user-agent-info.php @@ -64,19 +64,30 @@ class User_Agent_Info { * * @var null|string */ - private $platform = null; - const PLATFORM_WINDOWS = 'windows'; - const PLATFORM_IPHONE = 'iphone'; - const PLATFORM_IPOD = 'ipod'; - const PLATFORM_IPAD = 'ipad'; - const PLATFORM_BLACKBERRY = 'blackberry'; - const PLATFORM_BLACKBERRY_10 = 'blackberry_10'; - const PLATFORM_SYMBIAN = 'symbian_series60'; - const PLATFORM_SYMBIAN_S40 = 'symbian_series40'; - const PLATFORM_J2ME_MIDP = 'j2me_midp'; - const PLATFORM_ANDROID = 'android'; - const PLATFORM_ANDROID_TABLET = 'android_tablet'; - const PLATFORM_FIREFOX_OS = 'firefoxOS'; + private $platform = null; + const PLATFORM_WINDOWS = 'windows'; + const PLATFORM_IPHONE = 'iphone'; + const PLATFORM_IPOD = 'ipod'; + const PLATFORM_IPAD = 'ipad'; + const PLATFORM_BLACKBERRY = 'blackberry'; + const PLATFORM_BLACKBERRY_10 = 'blackberry_10'; + const PLATFORM_SYMBIAN = 'symbian_series60'; + const PLATFORM_SYMBIAN_S40 = 'symbian_series40'; + const PLATFORM_J2ME_MIDP = 'j2me_midp'; + const PLATFORM_ANDROID = 'android'; + const PLATFORM_ANDROID_TABLET = 'android_tablet'; + const PLATFORM_FIREFOX_OS = 'firefoxOS'; + const PLATFORM_DESKTOP_LINUX = 'linux'; + const PLATFORM_DESKTOP_MAC = 'mac'; + const PLATFORM_DESKTOP_WINDOWS = 'windows'; + const PLATFORM_DESKTOP_CHROME = 'chrome'; + const BROWSER_CHROME = 'chrome'; + const BROWSER_FIREFOX = 'firefox'; + const BROWSER_SAFARI = 'safari'; + const BROWSER_EDGE = 'edge'; + const BROWSER_OPERA = 'opera'; + const BROWSER_IE = 'ie'; + const OTHER = 'other'; /** * A list of dumb-phone user agent parts. @@ -277,6 +288,57 @@ public function get_platform() { return $this->platform; } + /** + * Returns the platform for desktops + * + * @return string + */ + public function get_desktop_platform() { + $ua = $this->useragent; + if ( empty( $ua ) ) { + return false; + } + $platform = self::OTHER; + + if ( static::is_linux_desktop() ) { + $platform = self::PLATFORM_DESKTOP_LINUX; + } elseif ( static::is_mac_desktop() ) { + $platform = self::PLATFORM_DESKTOP_MAC; + } elseif ( static::is_windows_desktop() ) { + $platform = self::PLATFORM_DESKTOP_WINDOWS; + } elseif ( static::is_chrome_desktop() ) { + $platform = self::PLATFORM_DESKTOP_CHROME; + } + return $platform; + } + + /** + * A simple pattern matching method for extracting the browser from the user agent. + * + * @return string + */ + public function get_browser() { + $ua = $this->useragent; + if ( empty( $ua ) ) { + return self::OTHER; + } + + if ( static::is_opera_mini() || static::is_opera_mobile() || static::is_opera_desktop() || static::is_opera_mini_dumb() ) { + return self::BROWSER_OPERA; + } elseif ( static::is_edge_browser() ) { + return self::BROWSER_EDGE; + } elseif ( static::is_chrome_desktop() || self::is_chrome_for_iOS() ) { + return self::BROWSER_CHROME; + } elseif ( static::is_safari_browser() ) { + return self::BROWSER_SAFARI; + } elseif ( static::is_firefox_mobile() || static::is_firefox_desktop() ) { + return self::BROWSER_FIREFOX; + } elseif ( static::is_ie_browser() ) { + return self::BROWSER_IE; + } + return self::OTHER; + } + /** * This method detects for UA which can display iPhone-optimized web content. * Includes iPhone, iPod Touch, Android, WebOS, Fennec (Firefox mobile), etc. @@ -714,6 +776,46 @@ public static function is_firefox_os() { } } + /** + * Detect Safari browser + */ + public static function is_safari_browser() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + if ( false === strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'Safari' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + return false; + } + return true; + } + + /** + * Detect Edge browser + */ + public static function is_edge_browser() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + if ( false === strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'Edge' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + return false; + } + return true; + } + + /** + * Detect Edge browser + */ + public static function is_ie_browser() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + $ua = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + if ( false === ( strpos( $ua, 'MSIE' ) || strpos( $ua, 'Trident/7' ) ) ) { + return false; + } + return true; + } + /** * Detect modern Opera desktop * @@ -1271,6 +1373,66 @@ public static function is_blackberry_10() { return ( strpos( $agent, 'bb10' ) !== false ) && ( strpos( $agent, 'mobile' ) !== false ); } + /** + * Determines whether a desktop platform is Linux OS + * + * @return bool + */ + public static function is_linux_desktop() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + if ( ! preg_match( '/linux/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + return false; + } + return true; + } + + /** + * Determines whether a desktop platform is Mac OS + * + * @return bool + */ + public static function is_mac_desktop() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + if ( ! preg_match( '/macintosh|mac os x/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + return false; + } + return true; + } + + /** + * Determines whether a desktop platform is Windows OS + * + * @return bool + */ + public static function is_windows_desktop() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + if ( ! preg_match( '/windows|win32/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + return false; + } + return true; + } + + /** + * Determines whether a desktop platform is Chrome OS + * + * @return bool + */ + public static function is_chrome_desktop() { + if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { + return false; + } + if ( ! preg_match( '/chrome/i', wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- This is validating. + return false; + } + return true; + } + /** * Retrieve the blackberry OS version. * diff --git a/projects/packages/device-detection/tests/php/test_DeviceDetection.php b/projects/packages/device-detection/tests/php/test_DeviceDetection.php index e8e98d02d12c2..586df96b611cb 100644 --- a/projects/packages/device-detection/tests/php/test_DeviceDetection.php +++ b/projects/packages/device-detection/tests/php/test_DeviceDetection.php @@ -47,6 +47,42 @@ public function test_is_mobile( $ua, array $expected_types, $expected_ua_returne $this->assertEquals( $device_info['is_phone'] ? $expected_ua_returned : false, $device_info['is_phone_matched_ua'] ); } + /** + * The get_browser tests. + * + * @param string $ua User agent string. + * @param array $expected_types Not used. + * @param bool $expected_ua_returned Not used. + * @param string $expected_browser Expected value for browser returned by the method. + * @return void + * + * @dataProvider ua_provider + */ + public function test_get_browser( string $ua, array $expected_types, $expected_ua_returned, string $expected_browser ) { + $_SERVER['HTTP_USER_AGENT'] = $ua; + + $device_info = Device_Detection::get_info( $ua ); + $actual_browser = $device_info['browser']; + $this->assertEquals( $expected_browser, $actual_browser ); + } + + /** + * The get_desktop_platform tests. + * + * @param string $ua User agent string. + * @param string $expected_platform Expected value for platform returned by the method. + * @return void + * + * @dataProvider ua_desktop_provider + */ + public function test_get_desktop_platform( string $ua, string $expected_platform ) { + $_SERVER['HTTP_USER_AGENT'] = $ua; + + $device_info = Device_Detection::get_info( $ua ); + $actual_platform = $device_info['desktop_platform']; + $this->assertEquals( $expected_platform, $actual_platform ); + } + /** * Data provider for test_is_mobile. * @@ -63,6 +99,7 @@ public function ua_provider() { 'is_handheld', ), 'nokia', + 'other', ), // Samsung Galaxy S8 smart phone. @@ -74,6 +111,7 @@ public function ua_provider() { 'is_handheld', ), 'android', + 'chrome', ), // iPhone X smart phone. @@ -85,6 +123,7 @@ public function ua_provider() { 'is_handheld', ), 'iphone', + 'safari', ), // iPad 2 10.5 tablet. @@ -95,6 +134,7 @@ public function ua_provider() { 'is_handheld', ), false, + 'other', ), // Kindle 3. @@ -107,6 +147,7 @@ public function ua_provider() { 'is_handheld', ), 'android', + 'safari', ), // Huawei p20 smartphone. @@ -118,6 +159,7 @@ public function ua_provider() { 'is_handheld', ), 'android', + 'chrome', ), // Googlebot smartphone. @@ -129,6 +171,7 @@ public function ua_provider() { 'is_handheld', ), 'android', + 'chrome', ), // Googlebot desktop. @@ -138,6 +181,47 @@ public function ua_provider() { 'is_desktop', ), false, + 'other', + ), + ); + } + + /** + * Data provider for get_desktop_platform. + * + * @return array + */ + public function ua_desktop_provider() { + return array( + + // Windows 10-based PC using Edge browser. + array( + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246', + 'windows', + ), + + // Chrome OS-based laptop using Chrome browser (Chromebook) + array( + 'Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36', + 'chrome', + ), + + // Mac OS X-based computer using a Safari browser + array( + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9', + 'mac', + ), + + // Windows 7-based PC using a Chrome browser + array( + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36', + 'windows', + ), + + // Linux-based PC using a Firefox browser + array( + 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1', + 'linux', ), ); } From 01c0a10faac50a5277b177d60b289cd11cc278c3 Mon Sep 17 00:00:00 2001 From: gogdzl <37049295+gogdzl@users.noreply.github.com> Date: Wed, 3 Apr 2024 09:53:02 -0300 Subject: [PATCH 19/23] Jetpack CRM: Font reinstallation improvements (#36704) * Delete fonts dir prior to reinstalling fonts * changelog --- projects/plugins/crm/admin/settings/locale.page.php | 9 ++++++++- .../crm/changelog/fix-jpcrm-3458-broken-pdf-due-to-fonts | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/crm/changelog/fix-jpcrm-3458-broken-pdf-due-to-fonts diff --git a/projects/plugins/crm/admin/settings/locale.page.php b/projects/plugins/crm/admin/settings/locale.page.php index 4508970885eab..d9ed711f136a3 100644 --- a/projects/plugins/crm/admin/settings/locale.page.php +++ b/projects/plugins/crm/admin/settings/locale.page.php @@ -27,11 +27,18 @@ // check for default font reinstalls if ( isset( $_GET['reinstall_default_font'] ) && zeroBSCRM_isZBSAdminOrAdmin() ) { - // check nonce check_admin_referer( 'zbs-update-settings-reinstall-font' ); // hard reinstall + require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'; + require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'; + $fonts_dir = jpcrm_storage_fonts_dir_path(); + if ( $fonts_dir ) { + $filesystem_direct = new WP_Filesystem_Direct( false ); + $filesystem_direct->rmdir( $fonts_dir, true ); + } + $fonts = $zbs->get_fonts(); $fonts->extract_and_install_default_fonts(); $default_font_reinstalled = true; diff --git a/projects/plugins/crm/changelog/fix-jpcrm-3458-broken-pdf-due-to-fonts b/projects/plugins/crm/changelog/fix-jpcrm-3458-broken-pdf-due-to-fonts new file mode 100644 index 0000000000000..7a45b0ac0eddb --- /dev/null +++ b/projects/plugins/crm/changelog/fix-jpcrm-3458-broken-pdf-due-to-fonts @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +PDF: Improved font reinstallation. From b0bbec5073ae6cdcfe888952d9b4ed5b0cf0b18b Mon Sep 17 00:00:00 2001 From: Aurorum <43215253+Aurorum@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:02:38 +0100 Subject: [PATCH 20/23] Newsletters: Add Filter for Timing of Subscribe Modal Pop-up (#36374) --- .../changelog/update-subscription-modal-load-time | 4 ++++ .../class-jetpack-subscribe-modal.php | 13 +++++++++++++ .../subscribe-modal/subscribe-modal.js | 3 ++- 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/update-subscription-modal-load-time diff --git a/projects/plugins/jetpack/changelog/update-subscription-modal-load-time b/projects/plugins/jetpack/changelog/update-subscription-modal-load-time new file mode 100644 index 0000000000000..037dc2c9c30f7 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-subscription-modal-load-time @@ -0,0 +1,4 @@ +Significance: minor +Type: enhancement + +Newsletters: Add filter that enables user to control the timing at which the Subscribe Modal loads. diff --git a/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php b/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php index 820b5b9c1e75d..2a7a7e9e07f88 100644 --- a/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php +++ b/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php @@ -62,6 +62,19 @@ public function enqueue_assets() { if ( $this->should_user_see_modal() ) { wp_enqueue_style( 'subscribe-modal-css', plugins_url( 'subscribe-modal.css', __FILE__ ), array(), JETPACK__VERSION ); wp_enqueue_script( 'subscribe-modal-js', plugins_url( 'subscribe-modal.js', __FILE__ ), array( 'wp-dom-ready' ), JETPACK__VERSION, true ); + + /** + * Filter how many milliseconds a user must scroll for until the Subscribe Modal appears. + * + * @module subscriptions + * + * @since $$next-version$$ + * + * @param int 300 Time in milliseconds for the Subscribe Modal to appear upon scrolling. + */ + $load_time = absint( apply_filters( 'jetpack_subscribe_modal_load_time', 300 ) ); + + wp_localize_script( 'subscribe-modal-js', 'Jetpack_Subscriptions', array( 'modalLoadTime' => $load_time ) ); } } diff --git a/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/subscribe-modal.js b/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/subscribe-modal.js index 19b5e399789c1..23c7c22c6be17 100644 --- a/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/subscribe-modal.js +++ b/projects/plugins/jetpack/modules/subscriptions/subscribe-modal/subscribe-modal.js @@ -1,3 +1,4 @@ +/* global Jetpack_Subscriptions */ const { domReady } = wp; domReady( function () { @@ -21,7 +22,7 @@ domReady( function () { if ( ! hasLoaded ) { openModal(); } - }, 300 ); + }, Jetpack_Subscriptions.modalLoadTime ); }; // User can edit modal, and could remove close link. From 41890da6595c7c6d4e4169e3cbeb2c653e3bf502 Mon Sep 17 00:00:00 2001 From: Thomas Roberts <5656702+opr@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:03:43 +0100 Subject: [PATCH 21/23] Woo Analytics: prevent accessing undefined wp.hooks on checkout (#36560) * Add checks for wp.hooks before accessing on checkout * Add changelog * bump version --------- Co-authored-by: Jeremy Herve --- .../changelog/fix-wp-hooks-check | 4 ++++ .../src/class-universal.php | 16 +++++++++------- .../src/class-woocommerce-analytics.php | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 projects/packages/woocommerce-analytics/changelog/fix-wp-hooks-check diff --git a/projects/packages/woocommerce-analytics/changelog/fix-wp-hooks-check b/projects/packages/woocommerce-analytics/changelog/fix-wp-hooks-check new file mode 100644 index 0000000000000..b21e5649fac99 --- /dev/null +++ b/projects/packages/woocommerce-analytics/changelog/fix-wp-hooks-check @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fixed a JavaScript error when accessing the Shortcode checkout with WooCommerce Analytics enabled diff --git a/projects/packages/woocommerce-analytics/src/class-universal.php b/projects/packages/woocommerce-analytics/src/class-universal.php index e4b2a69a32bd3..7ead8dacb08f3 100644 --- a/projects/packages/woocommerce-analytics/src/class-universal.php +++ b/projects/packages/woocommerce-analytics/src/class-universal.php @@ -244,14 +244,16 @@ function ( $payment_gateway ) { if ( true === cartItem_{$cart_item_key}_logged ) { return; } - wp.hooks.addAction( 'wcpay.payment-request.availability', 'wcpay', function ( args ) { - properties.express_checkout = args.paymentRequestType; - } ); - properties.checkout_page_contains_checkout_block = '0'; - properties.checkout_page_contains_checkout_shortcode = '1'; + if ( typeof wp !== 'undefined' && typeof wp.hooks !== 'undefined' && typeof wp.hooks.addAction === 'function' ) { + wp.hooks.addAction( 'wcpay.payment-request.availability', 'wcpay', function ( args ) { + properties.express_checkout = args.paymentRequestType; + } ); + } + properties.checkout_page_contains_checkout_block = '0'; + properties.checkout_page_contains_checkout_shortcode = '1'; - _wca.push( properties ); - cartItem_{$cart_item_key}_logged = true; + _wca.push( properties ); + cartItem_{$cart_item_key}_logged = true; } ); } diff --git a/projects/packages/woocommerce-analytics/src/class-woocommerce-analytics.php b/projects/packages/woocommerce-analytics/src/class-woocommerce-analytics.php index 8b92bac75d61a..8632ef0f4435c 100644 --- a/projects/packages/woocommerce-analytics/src/class-woocommerce-analytics.php +++ b/projects/packages/woocommerce-analytics/src/class-woocommerce-analytics.php @@ -20,7 +20,7 @@ class Woocommerce_Analytics { /** * Package version. */ - const PACKAGE_VERSION = '0.1.2'; + const PACKAGE_VERSION = '0.1.3-alpha'; /** * Initializer. From 72e68b823e77d3f72ed33e1961547e7b4350b7fe Mon Sep 17 00:00:00 2001 From: Peter Petrov Date: Wed, 3 Apr 2024 16:09:36 +0300 Subject: [PATCH 22/23] Boost: Add e2e tests for Image Guide (#36716) * Update Boost's CLI to include support for image guide module * Add e2e tests for image guide * Add Boost's image guide test configuration to e2e test matrix * add changelog --- .github/files/e2e-tests/e2e-matrix.js | 8 +++ .../assets/src/js/features/module/module.tsx | 2 +- projects/plugins/boost/app/lib/class-cli.php | 2 +- .../boost/changelog/add-e2e-tests-image-guide | 5 ++ .../boost/tests/e2e/lib/env/prerequisites.js | 16 ++++++ .../e2e/lib/pages/frontend/FirstPostPage.js | 24 +++++++++ .../boost/tests/e2e/lib/pages/index.js | 1 + .../e2e-appended-image/assets/e2e-image.png | Bin 0 -> 2727 bytes .../e2e-appended-image/e2e-appended-image.php | 21 ++++++++ .../e2e/specs/image-guide/image-guide.test.js | 50 ++++++++++++++++++ .../docker/jetpack-docker-config-default.yml | 1 + 11 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 projects/plugins/boost/changelog/add-e2e-tests-image-guide create mode 100644 projects/plugins/boost/tests/e2e/lib/pages/frontend/FirstPostPage.js create mode 100644 projects/plugins/boost/tests/e2e/plugins/e2e-appended-image/assets/e2e-image.png create mode 100644 projects/plugins/boost/tests/e2e/plugins/e2e-appended-image/e2e-appended-image.php create mode 100644 projects/plugins/boost/tests/e2e/specs/image-guide/image-guide.test.js diff --git a/.github/files/e2e-tests/e2e-matrix.js b/.github/files/e2e-tests/e2e-matrix.js index 2f9ef1cd249fb..2fe2e44f53220 100644 --- a/.github/files/e2e-tests/e2e-matrix.js +++ b/.github/files/e2e-tests/e2e-matrix.js @@ -58,6 +58,14 @@ const projects = [ suite: '', buildGroup: 'jetpack-boost', }, + { + project: 'Jetpack Boost - Image Guide', + path: 'projects/plugins/boost/tests/e2e', + testArgs: [ 'specs/image-guide', '--retries=1' ], + targets: [ 'plugins/boost' ], + suite: '', + buildGroup: 'jetpack-boost', + }, { project: 'Search', path: 'projects/plugins/search/tests/e2e', diff --git a/projects/plugins/boost/app/assets/src/js/features/module/module.tsx b/projects/plugins/boost/app/assets/src/js/features/module/module.tsx index 71d5c97434124..eaf40d209dde2 100644 --- a/projects/plugins/boost/app/assets/src/js/features/module/module.tsx +++ b/projects/plugins/boost/app/assets/src/js/features/module/module.tsx @@ -58,7 +58,7 @@ const Module = ( { } return ( -
+
{ toggle && ( ensureTestPosts( state.testPostTitles ), clean: () => ensureCleanState( state.clean ), mockSpeedScore: () => ensureMockSpeedScoreState( state.mockSpeedScore ), + appendImage: () => ensureAppendedImage( state.appendImage ), }; logger.prerequisites( JSON.stringify( state, null, 2 ) ); @@ -93,6 +99,16 @@ export async function ensureMockSpeedScoreState( mockSpeedScore ) { } } +export async function ensureAppendedImage( append ) { + if ( append ) { + logger.prerequisites( 'Appending image' ); + await execWpCommand( 'plugin activate e2e-appended-image/e2e-appended-image.php' ); + } else { + logger.prerequisites( 'Removing appended image' ); + await execWpCommand( 'plugin deactivate e2e-appended-image/e2e-appended-image.php' ); + } +} + export async function activateModules( modules ) { for ( const module of modules ) { logger.prerequisites( `Activating module ${ module }` ); diff --git a/projects/plugins/boost/tests/e2e/lib/pages/frontend/FirstPostPage.js b/projects/plugins/boost/tests/e2e/lib/pages/frontend/FirstPostPage.js new file mode 100644 index 0000000000000..3ccd30133b6dc --- /dev/null +++ b/projects/plugins/boost/tests/e2e/lib/pages/frontend/FirstPostPage.js @@ -0,0 +1,24 @@ +import WpPage from 'jetpack-e2e-commons/pages/wp-page.js'; +import { resolveSiteUrl } from 'jetpack-e2e-commons/helpers/utils-helper.js'; + +export default class FirstPostPage extends WpPage { + constructor( page ) { + const url = `${ resolveSiteUrl() }/?p=1`; + super( page, { url } ); + } + + async isImageGuideScriptPresent() { + const selector = '#jetpack-boost-guide-js'; + return ( await this.page.locator( selector ).count() ) > 0; + } + + async isImageGuideAdminBarItemPresent() { + const selector = '#wp-toolbar #jetpack-boost-guide-bar'; + return ( await this.page.locator( selector ).count() ) > 0; + } + + async isImageGuideUIPresent() { + const selector = '.jetpack-boost-guide > .guide'; + return this.waitForElementToBeVisible( selector, 5 * 1000 ); + } +} diff --git a/projects/plugins/boost/tests/e2e/lib/pages/index.js b/projects/plugins/boost/tests/e2e/lib/pages/index.js index 589048da796ce..474734695266c 100644 --- a/projects/plugins/boost/tests/e2e/lib/pages/index.js +++ b/projects/plugins/boost/tests/e2e/lib/pages/index.js @@ -1 +1,2 @@ export { default as JetpackBoostPage } from './wp-admin/JetpackBoostPage.js'; +export { default as FirstPostPage } from './frontend/FirstPostPage.js'; diff --git a/projects/plugins/boost/tests/e2e/plugins/e2e-appended-image/assets/e2e-image.png b/projects/plugins/boost/tests/e2e/plugins/e2e-appended-image/assets/e2e-image.png new file mode 100644 index 0000000000000000000000000000000000000000..94ec9a10839b4de1898f18b1261fa836d4894922 GIT binary patch literal 2727 zcmbtWcTm&W7LJqvp^72Wt8`F$78b;)KmdVI{Ymo&NHY)wVR2C*5TzIeM1rBCsI-8g z2_ixgr7c|`AZ<||(pA7vS9sBR|Gb%D?ykf3<7}& zTBFZ8K_DCe1ac^ymy;c_SpHnjHfYQ_7mJ>rp7iwe$B!RZRaJF#bkOPa!otFgjEv08 z%#xCl^78V!y1Kl)JTjS_m6i48&6}>Su7-vNDwX>B_3NCRoF`A7G&MEV)YJs>%-n}S zV3O8nQ7+fUSLpF<0SLb6d)d)4jvw3q4dCX?sh`ZwgZjfRuKx*R4Gl8JKJvUpIGq+9 z@eta|!9j41wPhk5S(zzg>oG5OrNKoR>ka+;LiUAAN-kI{E?uyx(630X&fNn>TfS%$ z!j3JdXWLikV^gbh3VtDcnJp!=y^2%`zP1>CFZ+^_Y}XDo__Emz<9xS3rnDbBoK}_h zlkh>!tWi_NNf&Bm2SovQ~>&61D|2S9dvGneO=fTeXjAMaAEGtDM5>|{}^_BiC zoYpFQPrPCB+^c&Gw6Vi?k%{SGpUk|tw6T!TY9VuV<7my+qZQ4d4rPCXJGj~JN}HUF zS4wfFP~0_(6Q4*^0y*~2u-XU*)%K?W>nwxrjnTv2PV!dX&RT&Co>5=YQ30b$wFU7! z0T~P40^204weAq(cw>p?%Y50T35-3P9X=4q*Nb{`LS_P|5q zBQi+%hc`V2UAB92JH9tDWxyQw^`;347cRAo#qDzoS!VC^6$_&B)s`B2d#2GQ)omG? zOvT!^-Q9#lRBtc!*}LrW({fh_S@4EYxNTD0faMep~J|r5JygO|8NEqI> zKa(MvxbFQSKqs^22{8)u0$}lfL^4lo_CyHyR)&DMNAb42;h^%o|xQyOvwknn=?f&XN9L;(gO#p+Tln6q-=u~2yxq+9f+1bEe z-d*_3l@41V;0($;4ef35w&P&;=By*V2+ABJMuNKU!&5Z}lbU*l!A zf>xuqRKN6xDNLEP(lE7_e7yqU`k(z41?(dy3@10fTy);!VoEwp9!Vf!b%I8Jy>I$r zwIw0hdYLbjf%%Y@ws9RlPdc7+=7H@n;qm*0WRI{l!wTrL*L-7Uv+BE?m9yu5>7$+p z!1VSx4|kR8ChAm`9#tI^>}&k(Pm;;N_TrWjwA;t$ ztwgOD+mLg6K+QpltC!uga_8Fwd(h#fUY9)=`G>d!B>xV ztOyx?bHslCQf&yo{wlhg#9I{5%T@7Io?tFG;u-od==6p%v|jY43Sbv^%{JgUlh1e7 zX}6^H-86wia0G${`fA{7G0J#iT9l%8@o=uZX+ed%9^FK}^H2QT zcBuVra84Xfy+i+amGaUCC$j8PPq*;z3GncdXeZQ9O5cjm0u1>PVHjGB5+J5bAAd7? zGRm&@I(8=c6ap~gWQI@JS>a9bZ4z+mG>@A@Fx3=lhIY0I6$0+}D@bW|B(zDvsjzOr z8!}jO1r$ zema9=F_*T)P0^zY@d7pCb>+MiV~*|v)H<#{*M(j_5E!;7Ee$lI4lT0?vF_Dzo7#A> zk?M8>pgnaDBjYty7|PkA$Nyyi**r-bNtUJ#6ye)a9D0QJ?Sr^M6!EQLthdqS*XEuSEio6^rgY`k82r8fzb z31^)QcW_Vuw0*XQw*D6|Ilwo{B7c_o@|aFh1j91jzhiM)vapVyvjw2potza)a1T6xlJ9C})0E-5uOL z>7&~fYhW&GVD23uDXXP*sTUfeQ<8w-`q8Ahc(Gx-rCS7;=guxZQ05kWcD&YU=*8vB zr#IyNI7N?3QB*81`9nQ=rb8=SJm?O2Mr=-k*rgdfZ)-sGyqnaR*G>_7Q;*i0CF|-R z&pn56E;Qse>o2{`;~QJ~Ztxz%w@JdO-rU%j zyQ%YM$`{>Im9DaTu{?JJiuI-WvcKbrgs4k-M61Pb4{9`VV_z?Tx}TDU`MIPy5rOQN zf0(jqY(gf?g#F$+FJz)t2y?aFstJWr+5_;09@(%zx!g)b2N!q3ar$K)w8G~F@^=0g zJQyaPQnZikD?br$*weKTX_^)oA#Qraa~)I;{Wdw#ig*Aa>Z^H}aD&y)Nqe9-pPrV6 zn0c)y2U4_?(m%SQu)lR_wK9e(JDeJ+G;8z}CSam$6F(QZ9i0?`u zJt7CPjQDB%tV@;MO83~s(UrK^k5O^{|0t@sQ7OtK)EYhui0q~u{{sos+hk5_PBzgc zXIbNyTCztL2Swh8kK)X7_qH~LrZd*gjA##l(~f3)OIs;sU0 zE2#7C-j!ih&%c;O3(sTkH!hf`

'; + } + return $content; + } +); diff --git a/projects/plugins/boost/tests/e2e/specs/image-guide/image-guide.test.js b/projects/plugins/boost/tests/e2e/specs/image-guide/image-guide.test.js new file mode 100644 index 0000000000000..767a7260c0a77 --- /dev/null +++ b/projects/plugins/boost/tests/e2e/specs/image-guide/image-guide.test.js @@ -0,0 +1,50 @@ +import { test, expect } from 'jetpack-e2e-commons/fixtures/base-test.js'; +import { boostPrerequisitesBuilder } from '../../lib/env/prerequisites.js'; +import { FirstPostPage } from '../../lib/pages/index.js'; +import playwrightConfig from 'jetpack-e2e-commons/playwright.config.mjs'; + +test.describe( 'Image CDN', () => { + let page; + + test.beforeAll( async ( { browser } ) => { + page = await browser.newPage( playwrightConfig.use ); + await boostPrerequisitesBuilder( page ).withCleanEnv( true ).withConnection( true ).build(); + } ); + + test.afterAll( async () => {} ); + + test( 'Image Guide functionality shouldn`t be active when the module is inactive', async () => { + await boostPrerequisitesBuilder( page ).withInactiveModules( [ 'image_guide' ] ).build(); + const firstPostPage = await FirstPostPage.visit( page ); + + expect( + await firstPostPage.isImageGuideScriptPresent(), + 'Image Guide script shouldn`t be present' + ).toBeFalsy(); + } ); + + test( 'Image Guide functionality should be active when the module is active', async () => { + await boostPrerequisitesBuilder( page ) + .withActiveModules( [ 'image_guide' ] ) + .withAppendedImage( true ) + .build(); + const firstPostPage = await FirstPostPage.visit( page ); + + expect( + await firstPostPage.isImageGuideScriptPresent(), + 'Image Guide script should be present' + ).toBeTruthy(); + + expect( + await firstPostPage.isImageGuideAdminBarItemPresent(), + 'Image Guide admin bar item should be present' + ).toBeTruthy(); + + console.log( await firstPostPage.isImageGuideUIPresent() ); + + expect( + await firstPostPage.isImageGuideUIPresent(), + 'Image Guide UI item should be present' + ).toBeTruthy(); + } ); +} ); diff --git a/tools/docker/jetpack-docker-config-default.yml b/tools/docker/jetpack-docker-config-default.yml index 63ac16823faa9..723e425b689e2 100644 --- a/tools/docker/jetpack-docker-config-default.yml +++ b/tools/docker/jetpack-docker-config-default.yml @@ -61,6 +61,7 @@ e2e: tools/e2e-commons/plugins/e2e-plugin-updater.php: /var/www/html/wp-content/plugins/e2e-plugin-updater.php tools/e2e-commons/plugins/e2e-plan-data-interceptor.php: /var/www/html/wp-content/plugins/e2e-plan-data-interceptor.php tools/e2e-commons/plugins/e2e-waf-data-interceptor.php: /var/www/html/wp-content/plugins/e2e-waf-data-interceptor.php + projects/plugins/boost/tests/e2e/plugins/e2e-appended-image/: /var/www/html/wp-content/plugins/e2e-appended-image/ projects/plugins/boost/tests/e2e/plugins/e2e-mock-speed-score-api.php: /var/www/html/wp-content/plugins/e2e-mock-speed-score-api.php tools/e2e-commons/plugins/e2e-search-test-helper.php: /var/www/html/wp-content/plugins/e2e-search-test-helper.php tools/e2e-commons/plugins/e2e-wpcom-request-interceptor.php: /var/www/html/wp-content/plugins/e2e-wpcom-request-interceptor.php From 5bfd7a99dafdad6e5ae7e1018fff8b5792ae1bc5 Mon Sep 17 00:00:00 2001 From: Kev Date: Wed, 3 Apr 2024 09:22:55 -0400 Subject: [PATCH 23/23] Sharing block: make sharing options translatable (#36642) * Sharing block: make sharing options translatable * Add comments for translators --- .../fix-sharing-blocks-not-translatable-text | 4 +++ .../blocks/sharing-button/variations.js | 26 ++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/fix-sharing-blocks-not-translatable-text diff --git a/projects/plugins/jetpack/changelog/fix-sharing-blocks-not-translatable-text b/projects/plugins/jetpack/changelog/fix-sharing-blocks-not-translatable-text new file mode 100644 index 0000000000000..ba4b7b90be7d6 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-sharing-blocks-not-translatable-text @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Sharing block: make sharing options translatable diff --git a/projects/plugins/jetpack/extensions/blocks/sharing-button/variations.js b/projects/plugins/jetpack/extensions/blocks/sharing-button/variations.js index a27a825e70f23..f1c3797c34013 100644 --- a/projects/plugins/jetpack/extensions/blocks/sharing-button/variations.js +++ b/projects/plugins/jetpack/extensions/blocks/sharing-button/variations.js @@ -10,8 +10,13 @@ export const variations = [ }, { name: 'print', - attributes: { service: 'print', label: 'Print' }, - title: 'Print', + attributes: { + service: 'print', + // translators: option to print the content - a verb. + label: __( 'Print', 'jetpack' ), + }, + // translators: option to print the content - a verb labelling a button. + title: __( 'Print', 'jetpack' ), icon: , }, { @@ -29,8 +34,13 @@ export const variations = [ }, { name: 'mail', - attributes: { service: 'mail', label: 'Mail' }, - title: 'Mail', + attributes: { + service: 'mail', + // translators: option to share the content by email - a verb. + label: __( 'Mail', 'jetpack' ), + }, + // translators: option to share the content by email - a verb labelling a button. + title: __( 'Mail', 'jetpack' ), keywords: [ 'email', 'e-mail' ], icon: , }, @@ -104,8 +114,12 @@ export const variations = [ }, { name: 'native-share', - attributes: { service: 'share', label: 'Share' }, - /* translators: Sharing Button title */ + attributes: { + service: 'share', + // translators: option to share the content - a verb. + label: __( 'Share', 'jetpack' ), + }, + // translators: option to share the content - a verb labelling a button. title: __( 'Native Share', 'jetpack' ), icon: , //TODO: we can add link in the future to proper documentation