@@ -56,6 +56,82 @@ public function setup_admin_hooks() {
56
56
add_action ( 'wp_ajax_neve_fse_dismiss_welcome_notice ' , array ( $ this , 'remove_welcome_notice ' ) );
57
57
add_action ( 'wp_ajax_neve_fse_dismiss_survey_notice ' , array ( $ this , 'remove_survey_notice ' ) );
58
58
add_action ( 'admin_print_scripts ' , array ( $ this , 'add_nps_form ' ) );
59
+
60
+ add_action ( 'enqueue_block_editor_assets ' , array ( $ this , 'add_fse_design_pack_notice ' ) );
61
+ add_action ( 'wp_ajax_neve_fse_dismiss_design_pack_notice ' , array ( $ this , 'remove_design_pack_notice ' ) );
62
+ }
63
+
64
+ /**
65
+ * Render design pack notice.
66
+ *
67
+ * @return void
68
+ */
69
+ public function add_fse_design_pack_notice () {
70
+ if ( ! $ this ->should_render_design_pack_notice () ) {
71
+ return ;
72
+ }
73
+
74
+ Assets_Manager::enqueue_style ( Assets_Manager::ASSETS_SLUGS ['design-pack-notice ' ], 'design-pack-notice ' );
75
+ Assets_Manager::enqueue_script (
76
+ Assets_Manager::ASSETS_SLUGS ['design-pack-notice ' ],
77
+ 'design-pack-notice ' ,
78
+ true ,
79
+ array (),
80
+ array (
81
+ 'nonce ' => wp_create_nonce ( 'neve-fse-dismiss-design-pack-notice ' ),
82
+ 'ajaxUrl ' => esc_url ( admin_url ( 'admin-ajax.php ' ) ),
83
+ 'ajaxAction ' => 'neve_fse_dismiss_design_pack_notice ' ,
84
+ 'buttonLink ' => tsdk_utmify ( 'https://themeisle.com/plugins/fse-design-pack ' , 'editor ' , 'neve-fse ' ),
85
+ 'strings ' => array (
86
+ 'dismiss ' => __ ( 'Dismiss ' , 'neve-fse ' ),
87
+ 'recommends ' => __ ( 'Neve FSE recommends ' , 'neve-fse ' ),
88
+ 'learnMore ' => __ ( 'Learn More ' , 'neve-fse ' ),
89
+ 'noticeHtml ' => sprintf (
90
+ /* translators: %s: FSE Design Pack: */
91
+ __ ( '%s Access a collection of 40+ layout patterns ready to import to your website ' , 'neve-fse ' ),
92
+ '<strong>FSE Design Pack:</strong> '
93
+ ),
94
+ ),
95
+ ),
96
+ 'designPackNoticeData '
97
+ );
98
+
99
+ echo '<div id="neve-fse-design-pack-notice"></div> ' ;
100
+ }
101
+
102
+ /**
103
+ * Should we show the design pack notice?
104
+ *
105
+ * @return bool
106
+ */
107
+ private function should_render_design_pack_notice () {
108
+ // Already using.
109
+ if ( is_plugin_active ( 'fse-design-pack/fse-design-pack.php ' ) ) {
110
+ return false ;
111
+ }
112
+
113
+ // Notice was dismissed.
114
+ if ( get_option ( Constants::CACHE_KEYS ['dismissed-fse-design-pack-notice ' ], 'no ' ) === 'yes ' ) {
115
+ return false ;
116
+ }
117
+
118
+ return true ;
119
+ }
120
+
121
+ /**
122
+ * Dismiss the design pack notice.
123
+ *
124
+ * @return void
125
+ */
126
+ public function remove_design_pack_notice () {
127
+ if ( ! isset ( $ _POST ['nonce ' ] ) ) {
128
+ return ;
129
+ }
130
+ if ( ! wp_verify_nonce ( sanitize_text_field ( $ _POST ['nonce ' ] ), 'neve-fse-dismiss-design-pack-notice ' ) ) {
131
+ return ;
132
+ }
133
+ update_option ( Constants::CACHE_KEYS ['dismissed-fse-design-pack-notice ' ], 'yes ' );
134
+ wp_die ();
59
135
}
60
136
61
137
/**
0 commit comments