From 2cbb9d59bc2b4b082579bcea5eaa73c71dd3a32a Mon Sep 17 00:00:00 2001 From: Chi-Hsuan Huang Date: Fri, 13 Sep 2024 09:11:11 +0800 Subject: [PATCH] Deprecate unsupported Inbox note banner layout (#51275) * Deprecate note banner layout * Update doc * Add changelog --- docs/docs-manifest.json | 4 ++-- docs/extension-development/handling-merchant-onboarding.md | 2 +- .../extensions/simple-inbox-note/class-simpleinboxnote.php | 2 +- plugins/woocommerce-beta-tester/api/admin-notes/add-note.php | 1 - .../changelog/update-deprecate-banner-layout | 4 ++++ plugins/woocommerce/changelog/update-deprecate-banner-layout | 4 ++++ plugins/woocommerce/src/Admin/Notes/Note.php | 5 +++++ .../src/Admin/RemoteInboxNotifications/SpecRunner.php | 3 +++ .../legacy/framework/helpers/class-wc-helper-admin-notes.php | 3 +-- 9 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 plugins/woocommerce-beta-tester/changelog/update-deprecate-banner-layout create mode 100644 plugins/woocommerce/changelog/update-deprecate-banner-layout diff --git a/docs/docs-manifest.json b/docs/docs-manifest.json index fa4faa93365..f7579ca4cef 100644 --- a/docs/docs-manifest.json +++ b/docs/docs-manifest.json @@ -727,7 +727,7 @@ "menu_title": "Implement merchant onboarding", "tags": "how-to", "edit_url": "https://github.com/woocommerce/woocommerce/edit/trunk/docs/extension-development/handling-merchant-onboarding.md", - "hash": "c73e3c5015e6cda3be9ebd2d5fbda590ac9fa599e5fb02163c971c01060970ad", + "hash": "85fc7d70f47fdb195ad2c690d3b95565169221f9e4d7afa98e88f3824ad0e267", "url": "https://raw.githubusercontent.com/woocommerce/woocommerce/trunk/docs/extension-development/handling-merchant-onboarding.md", "id": "89fe15dc232379f546852822230c334d3d940b93" }, @@ -1804,5 +1804,5 @@ "categories": [] } ], - "hash": "1f651a59399c34644d2f91a0366bbd01da2c7dc677a1c53329b184badd3b8d13" + "hash": "77c102c35a45b0681e7b70def9d639d764e4e5068121c2ef4dd23477c0f8784c" } \ No newline at end of file diff --git a/docs/extension-development/handling-merchant-onboarding.md b/docs/extension-development/handling-merchant-onboarding.md index 3dec70d6f89..5b3adaed57d 100644 --- a/docs/extension-development/handling-merchant-onboarding.md +++ b/docs/extension-development/handling-merchant-onboarding.md @@ -448,7 +448,7 @@ class ExampleNote { $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); // Set the type of layout the note uses. Supported layout types are: - // 'banner', 'plain', 'thumbnail' + // 'plain', 'thumbnail' $note->set_layout( 'plain' ); // Set the image for the note. This property renders as the src diff --git a/plugins/woocommerce-admin/docs/examples/extensions/simple-inbox-note/class-simpleinboxnote.php b/plugins/woocommerce-admin/docs/examples/extensions/simple-inbox-note/class-simpleinboxnote.php index f62ee908ee9..23cb3cf937d 100644 --- a/plugins/woocommerce-admin/docs/examples/extensions/simple-inbox-note/class-simpleinboxnote.php +++ b/plugins/woocommerce-admin/docs/examples/extensions/simple-inbox-note/class-simpleinboxnote.php @@ -83,7 +83,7 @@ class SimpleInboxNote { $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); // Set the type of layout the note uses. Supported layout types are: - // 'banner', 'plain', 'thumbnail'. + // 'plain', 'thumbnail'. $note->set_layout( 'plain' ); // Set the image for the note. This property renders as the src diff --git a/plugins/woocommerce-beta-tester/api/admin-notes/add-note.php b/plugins/woocommerce-beta-tester/api/admin-notes/add-note.php index bf5d85a6377..41711630762 100644 --- a/plugins/woocommerce-beta-tester/api/admin-notes/add-note.php +++ b/plugins/woocommerce-beta-tester/api/admin-notes/add-note.php @@ -73,7 +73,6 @@ function get_mock_note_data() { return array( 'content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.', 'info' => array( - 'banner' => $plugin_url . 'images/admin-notes/banner.jpg', 'thumbnail' => $plugin_url . 'images/admin-notes/thumbnail.jpg', 'plain' => '', ), diff --git a/plugins/woocommerce-beta-tester/changelog/update-deprecate-banner-layout b/plugins/woocommerce-beta-tester/changelog/update-deprecate-banner-layout new file mode 100644 index 00000000000..4af22693683 --- /dev/null +++ b/plugins/woocommerce-beta-tester/changelog/update-deprecate-banner-layout @@ -0,0 +1,4 @@ +Significance: patch +Type: update + +Deprecate unsupported Inbox note banner layout diff --git a/plugins/woocommerce/changelog/update-deprecate-banner-layout b/plugins/woocommerce/changelog/update-deprecate-banner-layout new file mode 100644 index 00000000000..4af22693683 --- /dev/null +++ b/plugins/woocommerce/changelog/update-deprecate-banner-layout @@ -0,0 +1,4 @@ +Significance: patch +Type: update + +Deprecate unsupported Inbox note banner layout diff --git a/plugins/woocommerce/src/Admin/Notes/Note.php b/plugins/woocommerce/src/Admin/Notes/Note.php index af986572efa..9058906d87b 100644 --- a/plugins/woocommerce/src/Admin/Notes/Note.php +++ b/plugins/woocommerce/src/Admin/Notes/Note.php @@ -579,6 +579,11 @@ class Note extends \WC_Data { $layout = 'plain'; } $valid_layouts = array( 'banner', 'plain', 'thumbnail' ); + + if ( 'banner' === $layout ) { + wc_deprecated_argument( 'Note::set_layout', '9.4.0', 'The "banner" layout is deprecated. Please use "thumbnail" instead to display a image.' ); + } + if ( in_array( $layout, $valid_layouts, true ) ) { $this->set_prop( 'layout', $layout ); } else { diff --git a/plugins/woocommerce/src/Admin/RemoteInboxNotifications/SpecRunner.php b/plugins/woocommerce/src/Admin/RemoteInboxNotifications/SpecRunner.php index dee3a29dfae..fe01ad82607 100644 --- a/plugins/woocommerce/src/Admin/RemoteInboxNotifications/SpecRunner.php +++ b/plugins/woocommerce/src/Admin/RemoteInboxNotifications/SpecRunner.php @@ -72,6 +72,9 @@ class SpecRunner { if ( isset( $spec->source ) ) { $note->set_source( $spec->source ); } + if ( isset( $spec->layout ) ) { + $note->set_layout( $spec->layout ); + } // Recreate actions. $note->set_actions( self::get_actions( $spec ) ); diff --git a/plugins/woocommerce/tests/legacy/framework/helpers/class-wc-helper-admin-notes.php b/plugins/woocommerce/tests/legacy/framework/helpers/class-wc-helper-admin-notes.php index 66f12f2a352..247d3c5fa84 100644 --- a/plugins/woocommerce/tests/legacy/framework/helpers/class-wc-helper-admin-notes.php +++ b/plugins/woocommerce/tests/legacy/framework/helpers/class-wc-helper-admin-notes.php @@ -60,7 +60,7 @@ class WC_Helper_Admin_Notes { $note_2->set_source( 'PHPUNIT_TEST' ); $note_2->set_status( Note::E_WC_ADMIN_NOTE_ACTIONED ); $note_2->set_is_snoozable( true ); - $note_2->set_layout( 'banner' ); + $note_2->set_layout( 'thumbnail' ); $note_2->set_image( 'https://an-image.jpg' ); // This note has no actions. $note_2->save(); @@ -100,7 +100,6 @@ class WC_Helper_Admin_Notes { '?s=PHPUNIT_TEST_NOTE_4_ACTION_2_URL' ); $note_4->save(); - } /**