@@ -59,6 +59,24 @@ class Feedzy_Rss_Feeds_Admin extends Feedzy_Rss_Feeds_Admin_Abstract {
59
59
public function __construct ( $ plugin_name , $ version ) {
60
60
$ this ->plugin_name = $ plugin_name ;
61
61
$ this ->version = $ version ;
62
+
63
+ if ( ! defined ( 'E2E_TESTING ' ) ) {
64
+ add_filter (
65
+ 'themeisle-sdk/survey/ ' . $ this ->plugin_name ,
66
+ function ( $ config , $ page_slug ) {
67
+
68
+ // Show survey only on `Help us improve` tab on Support page.
69
+ if ( strpos ( $ page_slug , 'support ' ) !== false && $ page_slug !== 'support-improve ' ) {
70
+ return $ config ;
71
+ }
72
+
73
+ $ config ['data ' ] = $ this ->get_survey_data ();
74
+ return $ config ;
75
+ },
76
+ 10 ,
77
+ 2
78
+ );
79
+ }
62
80
}
63
81
64
82
/**
@@ -129,7 +147,8 @@ public function enqueue_styles_admin() {
129
147
}
130
148
131
149
if ( 'feedzy_imports ' === $ screen ->post_type && 'edit ' === $ screen ->base ) {
132
- $ this ->register_survey ();
150
+ $ this ->do_internal_page ( 'imports ' );
151
+
133
152
$ this ->add_banner_anchor ();
134
153
}
135
154
@@ -157,8 +176,6 @@ public function enqueue_styles_admin() {
157
176
),
158
177
)
159
178
);
160
-
161
- $ this ->register_survey ();
162
179
$ this ->add_banner_anchor ();
163
180
}
164
181
@@ -179,8 +196,6 @@ public function enqueue_styles_admin() {
179
196
),
180
197
)
181
198
);
182
-
183
- $ this ->register_survey ();
184
199
}
185
200
186
201
if (
@@ -238,24 +253,32 @@ public function enqueue_styles_admin() {
238
253
wp_enqueue_style ( 'wp-block-editor ' );
239
254
240
255
wp_set_script_translations ( $ this ->plugin_name . '_conditions ' , 'feedzy-rss-feeds ' );
241
-
242
- $ this ->register_survey ();
243
256
}
244
257
if ( ! defined ( 'TI_CYPRESS_TESTING ' ) && ( 'edit ' !== $ screen ->base && 'feedzy_imports ' === $ screen ->post_type && feedzy_show_import_tour () ) ) {
245
258
$ asset_file = include FEEDZY_ABSPATH . '/build/onboarding/index.asset.php ' ;
246
259
wp_enqueue_script ( $ this ->plugin_name . '_on_boarding ' , FEEDZY_ABSURL . 'build/onboarding/index.js ' , array_merge ( $ asset_file ['dependencies ' ], array ( 'wp-editor ' , 'wp-api ' ) ), $ asset_file ['version ' ], true );
247
260
wp_set_script_translations ( $ this ->plugin_name . '_on_boarding ' , 'feedzy-rss-feeds ' );
248
261
}
249
262
263
+ if ( 'feedzy_page_feedzy-settings ' === $ screen ->base ) {
264
+ $ this ->do_internal_page ( 'settings ' );
265
+ }
266
+
267
+ if ( 'feedzy_page_feedzy-integration ' === $ screen ->base ) {
268
+ $ this ->do_internal_page ( 'integrations ' );
269
+ }
270
+
271
+ if ( 'feedzy_categories ' === $ screen ->post_type ) {
272
+ $ this ->do_internal_page ( 'add ' === $ screen ->action ? 'new-category ' : 'categories ' );
273
+ }
274
+
250
275
if ( ! in_array ( $ screen ->base , $ upsell_screens , true ) && strpos ( $ screen ->id , 'feedzy ' ) === false ) {
251
276
return ;
252
277
}
253
278
254
279
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
255
280
if ( 'feedzy_page_feedzy-support ' === $ screen ->base && ( isset ( $ _GET ['tab ' ] ) && 'improve ' === $ _GET ['tab ' ] ) || ( 'edit ' !== $ screen ->base && 'feedzy_imports ' === $ screen ->post_type ) ) {
256
281
257
- $ this ->register_survey ();
258
-
259
282
$ asset_file = include FEEDZY_ABSPATH . '/build/feedback/index.asset.php ' ;
260
283
wp_enqueue_script ( $ this ->plugin_name . '_feedback ' , FEEDZY_ABSURL . 'build/feedback/index.js ' , array_merge ( $ asset_file ['dependencies ' ], array ( 'wp-editor ' , 'wp-api ' , 'lodash ' ) ), $ asset_file ['version ' ], true );
261
284
wp_enqueue_style ( 'wp-block-editor ' );
@@ -272,6 +295,17 @@ public function enqueue_styles_admin() {
272
295
wp_set_script_translations ( $ this ->plugin_name . '_feedback ' , 'feedzy-rss-feeds ' );
273
296
}
274
297
298
+ if ( 'feedzy_page_feedzy-support ' === $ screen ->base ) {
299
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
300
+ $ tab = isset ( $ _GET ['tab ' ] ) ? sanitize_text_field ( wp_unslash ( $ _GET ['tab ' ] ) ) : '' ;
301
+ $ suffix = ! empty ( $ tab ) ? '- ' . $ tab : '' ;
302
+ $ this ->do_internal_page ( 'support ' . $ suffix );
303
+ }
304
+
305
+ if ( ( 'edit ' !== $ screen ->base && 'feedzy_imports ' === $ screen ->post_type ) ) {
306
+ $ this ->do_internal_page ( 'new-import ' );
307
+ }
308
+
275
309
if ( 'feedzy_imports ' === $ screen ->post_type && 'edit ' === $ screen ->base && feedzy_show_review_notice () ) {
276
310
$ asset_file = include FEEDZY_ABSPATH . '/build/review/index.asset.php ' ;
277
311
wp_enqueue_script ( $ this ->plugin_name . '_review ' , FEEDZY_ABSURL . 'build/review/index.js ' , $ asset_file ['dependencies ' ], $ asset_file ['version ' ], true );
@@ -2026,20 +2060,11 @@ public static function plan_category( $license_data ) {
2026
2060
* @return array
2027
2061
* @see survey.js
2028
2062
*/
2029
- public function get_survery_metadata () {
2030
-
2031
- $ user_id = 'feedzy_ ' ;
2032
- $ license_data = get_option ( 'feedzy_rss_feeds_pro_license_data ' , array () );
2033
-
2034
- if ( ! empty ( $ license_data ->key ) ) {
2035
- $ user_id .= $ license_data ->key ;
2036
- } else {
2037
- $ user_id .= preg_replace ( '/[^\w\d]*/ ' , '' , get_site_url () ); // Use a normalized version of the site URL as a user ID for free users.
2038
- }
2039
-
2063
+ public function get_survey_data () {
2064
+ $ license_data = get_option ( 'feedzy_rss_feeds_pro_license_data ' , array () );
2040
2065
$ integration_status = $ this ->api_license_status ();
2041
2066
2042
- $ days_since_install = round ( ( time () - get_option ( 'feedzy_rss_feeds_install ' , 0 ) ) / DAY_IN_SECONDS );
2067
+ $ days_since_install = round ( ( time () - get_option ( 'feedzy_rss_feeds_install ' , time () ) ) / DAY_IN_SECONDS );
2043
2068
$ install_category = 0 ;
2044
2069
if ( 0 === $ days_since_install || 1 === $ days_since_install ) {
2045
2070
$ install_category = 0 ;
@@ -2054,44 +2079,23 @@ public function get_survery_metadata() {
2054
2079
}
2055
2080
2056
2081
return array (
2057
- 'userId ' => $ user_id ,
2058
- 'attributes ' => array (
2059
- 'free_version ' => $ this ->version ,
2060
- 'pro_version ' => defined ( 'FEEDZY_PRO_VERSION ' ) ? FEEDZY_PRO_VERSION : '' ,
2061
- 'openai ' => $ integration_status ['openaiStatus ' ] ? 'valid ' : 'invalid ' ,
2062
- 'amazon ' => $ integration_status ['amazonStatus ' ] ? 'valid ' : 'invalid ' ,
2063
- 'spinnerchief ' => $ integration_status ['spinnerChiefStatus ' ] ? 'valid ' : 'invalid ' ,
2064
- 'wordai ' => $ integration_status ['wordaiStatus ' ] ? 'valid ' : 'invalid ' ,
2065
- 'plan ' => $ this ->plan_category ( $ license_data ),
2066
- 'days_since_install ' => $ install_category ,
2067
- 'license_status ' => ! empty ( $ license_data ->license ) ? $ license_data ->license : 'invalid ' ,
2082
+ 'environmentId ' => 'clskgehf78eu5podwdrnzciti ' ,
2083
+ 'apiHost ' => 'https://app.formbricks.com ' ,
2084
+ 'attributes ' => array (
2085
+ 'free_version ' => $ this ->version ,
2086
+ 'pro_version ' => defined ( 'FEEDZY_PRO_VERSION ' ) ? FEEDZY_PRO_VERSION : '' ,
2087
+ 'openai ' => $ integration_status ['openaiStatus ' ] ? 'valid ' : 'invalid ' ,
2088
+ 'amazon ' => $ integration_status ['amazonStatus ' ] ? 'valid ' : 'invalid ' ,
2089
+ 'spinnerchief ' => $ integration_status ['spinnerChiefStatus ' ] ? 'valid ' : 'invalid ' ,
2090
+ 'wordai ' => $ integration_status ['wordaiStatus ' ] ? 'valid ' : 'invalid ' ,
2091
+ 'plan ' => $ this ->plan_category ( $ license_data ),
2092
+ 'days_since_install ' => $ install_category ,
2093
+ 'install_days_number ' => $ days_since_install ,
2094
+ 'license_status ' => ! empty ( $ license_data ->license ) ? $ license_data ->license : 'invalid ' ,
2068
2095
),
2069
2096
);
2070
2097
}
2071
2098
2072
- /**
2073
- * Register the survey script.
2074
- *
2075
- * It does register if we are in CI environment.
2076
- *
2077
- * @return void
2078
- */
2079
- public function register_survey () {
2080
-
2081
- if ( defined ( 'CYPRESS_TESTING ' ) ) {
2082
- return ;
2083
- }
2084
-
2085
- $ survey_handler = apply_filters ( 'themeisle_sdk_dependency_script_handler ' , 'survey ' );
2086
- if ( empty ( $ survey_handler ) ) {
2087
- return ;
2088
- }
2089
-
2090
- do_action ( 'themeisle_sdk_dependency_enqueue_script ' , 'survey ' );
2091
- wp_enqueue_script ( $ this ->plugin_name . '_survey ' , FEEDZY_ABSURL . 'js/survey.js ' , array ( $ survey_handler ), $ this ->version , true );
2092
- wp_localize_script ( $ this ->plugin_name . '_survey ' , 'feedzySurveyData ' , $ this ->get_survery_metadata () );
2093
- }
2094
-
2095
2099
/**
2096
2100
* Add banner anchor for promotions.
2097
2101
*/
@@ -2332,4 +2336,11 @@ public function register_settings() {
2332
2336
)
2333
2337
);
2334
2338
}
2339
+
2340
+ /**
2341
+ * Mark the page as internal.
2342
+ */
2343
+ private function do_internal_page ( $ page_slug ) {
2344
+ do_action ( 'themeisle_internal_page ' , $ this ->plugin_name , $ page_slug );
2345
+ }
2335
2346
}
0 commit comments