Skip to content

Commit ae7be0f

Browse files
committed
show notices for users with addons installed
- + guard against error for git-based plugin update (without re-activation)
1 parent af012ef commit ae7be0f

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/AdminNotices.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ public static function showAdminNotices() : void {
3737
return;
3838
}
3939

40+
// avoid missing table error for git users who don't re-activate plugin
41+
global $wpdb;
42+
$table_name = $wpdb->prefix . 'wp2static_notices';
43+
44+
$check_table_query =
45+
$wpdb->prepare(
46+
'SHOW TABLES LIKE %s',
47+
$wpdb->esc_like( $table_name )
48+
);
49+
50+
if ( $wpdb->get_var( $check_table_query ) !== $table_name ) {
51+
return;
52+
}
53+
4054
$notice_to_display = ( new self() )->getNoticeBasedOnRules();
4155

4256
if ( ! $notice_to_display ) {
@@ -131,7 +145,14 @@ public function getNoticeBasedOnRules() {
131145
'secondary_button_title' => 'Learn more',
132146
];
133147

134-
if ( ! ( new self() )->noticeAlreadyDismissed( 'elementor-pro' ) &&
148+
$addons = Addons::getAll();
149+
150+
if ( ! ( new self() )->noticeAlreadyDismissed( 'wp2static-addons-installed' ) &&
151+
$addons !== []
152+
) {
153+
$notice['name'] = 'wp2static-addons-installed';
154+
$notice = array_merge( ( new self() )->getNoticeContents( 'wp2static-addons-installed' ), $notice );
155+
} elseif ( ! ( new self() )->noticeAlreadyDismissed( 'elementor-pro' ) &&
135156
is_plugin_active( 'elementor-pro/elementor-pro.php' )
136157
) {
137158
$notice['name'] = 'elementor-pro';
@@ -356,6 +377,16 @@ public function getNoticeContents( string $notice_name ) {
356377
'secondary_button_url' => 'https://link.strattic.com/learn-strattic-redirect',
357378
];
358379
break;
380+
case 'wp2static-addons-installed':
381+
$notice_contents = [
382+
'title' =>
383+
'Strattic by Elementor: The simplest way to publish powerful static sites!',
384+
// phpcs:disable Generic.Files.LineLength.MaxExceeded
385+
'message' => "Enjoy blindingly fast, secure and simple WordPress static hosting, with dozens of dynamic features. \nGet 14 days for free. No credit card required!",
386+
'primary_button_url' => 'https://link.strattic.com/try-strattic-publish',
387+
'secondary_button_url' => 'https://link.strattic.com/learn-strattic-publish',
388+
];
389+
break;
359390
}
360391

361392
return $notice_contents;

0 commit comments

Comments
 (0)