Skip to content

Commit d015e4c

Browse files
Closes #7294: Update banner for 3.19 (PR #7381)
Co-authored-by: WordPressFan <[email protected]>
1 parent 2ffbe14 commit d015e4c

File tree

4 files changed

+43
-29
lines changed

4 files changed

+43
-29
lines changed

inc/Engine/Admin/Beacon/Beacon.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -821,16 +821,6 @@ public function get_suggest( $doc_id ) {
821821
'url' => 'https://fr.docs.wp-rocket.me/article/1833-impossible-creer-table-rucssusedcss/?utm_source=wp_plugin&utm_medium=wp_rocket',
822822
],
823823
],
824-
'lazy_render_content' => [
825-
'en' => [
826-
'id' => '66b11e26a62a7505fcf339e7',
827-
'url' => 'https://docs.wp-rocket.me/article/1835-lazy-render-content/?utm_source=wp_plugin&utm_medium=wp_rocket',
828-
],
829-
'fr' => [
830-
'id' => '66ba0e8e082392452a0773ea',
831-
'url' => 'https://fr.docs.wp-rocket.me/article/1836-rendu-differe-automatique/?utm_source=wp_plugin&utm_medium=wp_rocket',
832-
],
833-
],
834824
'host_fonts_locally' => [
835825
'en' => [
836826
'id' => '673358b02ddbd952f6241b38',
@@ -841,6 +831,16 @@ public function get_suggest( $doc_id ) {
841831
'url' => 'https://fr.docs.wp-rocket.me/article/1852-auto-heberger-google-fonts?utm_source=wp_plugin&utm_medium=wp_rocket',
842832
],
843833
],
834+
'preconnect_domains' => [
835+
'en' => [
836+
'id' => '681b61d889bd957cd04bd2d9',
837+
'url' => 'https://docs.wp-rocket.me/article/1869-preconnect-to-external-domains',
838+
],
839+
'fr' => [
840+
'id' => '681da5ae11561a04f5de356e',
841+
'url' => 'https://fr.docs.wp-rocket.me/article/1870-preconnexion-aux-domaines-externes',
842+
],
843+
],
844844
];
845845

846846
return isset( $suggest[ $doc_id ][ $this->get_user_locale() ] )

inc/Engine/Admin/Settings/Page.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,29 +2255,24 @@ public function display_update_notice() {
22552255

22562256
$previous_version = $this->options->get( 'previous_version' );
22572257

2258-
// Bail-out for fresh install.
2259-
if ( empty( $previous_version ) ) {
2258+
// Bail-out if previous version is greater than or equal to 3.19.
2259+
if ( version_compare( $previous_version, '3.19', '>=' ) ) {
22602260
return;
22612261
}
22622262

2263-
// Bail-out if previous version is greater than 3.17.
2264-
if ( $previous_version > '3.17' ) {
2265-
return;
2266-
}
2267-
2268-
$lazy_render_content = $this->beacon->get_suggest( 'lazy_render_content' );
2263+
$preconnect_content = $this->beacon->get_suggest( 'preconnect_domains' );
22692264

22702265
rocket_notice_html(
22712266
[
22722267
'status' => 'info',
22732268
'dismissible' => '',
22742269
'message' => sprintf(
2275-
// translators: %1$s: opening strong tag, %2$s: closing strong tag, %3$s: opening a tag, %4$s: opening a tag.
2276-
__( '%1$sWP Rocket:%2$s the plugin has been updated to the 3.17 version. New feature: %3$sAutomatic Lazy Rendering%4$s. Check out our documentation to learn more about it.', 'rocket' ),
2277-
'<strong>',
2278-
'</strong>',
2279-
'<a href="' . esc_url( $lazy_render_content['url'] ) . '" data-beacon-article="' . esc_attr( $lazy_render_content['id'] ) . '" target="_blank" rel="noopener noreferrer">',
2280-
'</a>'
2270+
// translators: %1$s: opening strong tag, %2$s: closing strong tag, %3$s: opening a tag, %4$s: closing a tag.
2271+
__( '%1$sWP Rocket:%2$s the plugin has been updated to the 3.19 version. New feature: %3$sPreconnect to external domains%4$s. Check out our documentation to learn more about it.', 'rocket' ),
2272+
'<strong>',
2273+
'</strong>',
2274+
'<a href="' . esc_url( $preconnect_content['url'] ) . '" data-beacon-article="' . esc_attr( $preconnect_content['id'] ) . '" target="_blank" rel="noopener noreferrer">',
2275+
'</a>'
22812276
),
22822277
'dismiss_button' => 'rocket_update_notice',
22832278
]

inc/Engine/Admin/Settings/Subscriber.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,21 @@ public static function get_subscribed_events() {
7070
'admin_notices' => 'display_update_notice',
7171
];
7272

73-
return array_merge( $events, PluginFamily::get_subscribed_events() );
73+
foreach ( PluginFamily::get_subscribed_events() as $hook => $callback ) {
74+
if ( isset( $events[ $hook ] ) ) {
75+
// Make sure it's an array of callbacks.
76+
if ( ! is_array( $events[ $hook ][0] ) ) {
77+
$events[ $hook ] = [ $events[ $hook ] ];
78+
}
79+
80+
// Wrap single callback in array if needed.
81+
$events[ $hook ][] = is_array( $callback ) ? $callback : [ $callback ];
82+
} else {
83+
$events[ $hook ] = is_array( $callback ) ? $callback : [ [ $callback ] ];
84+
}
85+
}
86+
87+
return $events;
7488
}
7589

7690
/**

tests/Fixtures/inc/Engine/Admin/Settings/Page/displayUpdateNotice.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
],
4949
'expected' => null,
5050
],
51-
'testShouldDoNothingWhenFirstInstall' => [
51+
'testShouldShowNoticeWhenFirstInstall' => [
5252
'config' => [
5353
'capability' => true,
5454
'screen' => (object) [
@@ -61,7 +61,12 @@
6161
'url' => 'http://example.org',
6262
],
6363
],
64-
'expected' => null,
64+
'expected' => [
65+
'status' => 'info',
66+
'dismissible' => '',
67+
'message' => '<strong>WP Rocket:</strong> the plugin has been updated to the 3.19 version. New feature: <a href="http://example.org" data-beacon-article="123" target="_blank" rel="noopener noreferrer">Preconnect to external domains</a>. Check out our documentation to learn more about it.',
68+
'dismiss_button' => 'rocket_update_notice',
69+
],
6570
],
6671
'testShouldDoNothingWhenVersionGT317' => [
6772
'config' => [
@@ -70,7 +75,7 @@
7075
'id' => 'settings_page_wprocket',
7176
],
7277
'boxes' => [],
73-
'previous_version' => '3.17.1',
78+
'previous_version' => '3.19.1',
7479
'beacon' => null,
7580
],
7681
'expected' => null,
@@ -91,7 +96,7 @@
9196
'expected' => [
9297
'status' => 'info',
9398
'dismissible' => '',
94-
'message' => '<strong>WP Rocket:</strong> the plugin has been updated to the 3.17 version. New feature: <a href="http://example.org" data-beacon-article="123" target="_blank" rel="noopener noreferrer">Automatic Lazy Rendering</a>. Check out our documentation to learn more about it.',
99+
'message' => '<strong>WP Rocket:</strong> the plugin has been updated to the 3.19 version. New feature: <a href="http://example.org" data-beacon-article="123" target="_blank" rel="noopener noreferrer">Preconnect to external domains</a>. Check out our documentation to learn more about it.',
95100
'dismiss_button' => 'rocket_update_notice',
96101
],
97102
],

0 commit comments

Comments
 (0)