@@ -59,6 +59,23 @@ 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 ( $ data , $ 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 $ data ;
71
+ }
72
+
73
+ return $ this ->get_survey_data ();
74
+ },
75
+ 10 ,
76
+ 2
77
+ );
78
+ }
62
79
}
63
80
64
81
/**
@@ -129,7 +146,8 @@ public function enqueue_styles_admin() {
129
146
}
130
147
131
148
if ( 'feedzy_imports ' === $ screen ->post_type && 'edit ' === $ screen ->base ) {
132
- $ this ->register_survey ();
149
+ $ this ->do_internal_page ( 'imports ' );
150
+
133
151
$ this ->add_banner_anchor ();
134
152
}
135
153
@@ -157,8 +175,6 @@ public function enqueue_styles_admin() {
157
175
),
158
176
)
159
177
);
160
-
161
- $ this ->register_survey ();
162
178
$ this ->add_banner_anchor ();
163
179
}
164
180
@@ -179,8 +195,6 @@ public function enqueue_styles_admin() {
179
195
),
180
196
)
181
197
);
182
-
183
- $ this ->register_survey ();
184
198
}
185
199
186
200
if (
@@ -238,24 +252,32 @@ public function enqueue_styles_admin() {
238
252
wp_enqueue_style ( 'wp-block-editor ' );
239
253
240
254
wp_set_script_translations ( $ this ->plugin_name . '_conditions ' , 'feedzy-rss-feeds ' );
241
-
242
- $ this ->register_survey ();
243
255
}
244
256
if ( ! defined ( 'TI_CYPRESS_TESTING ' ) && ( 'edit ' !== $ screen ->base && 'feedzy_imports ' === $ screen ->post_type && feedzy_show_import_tour () ) ) {
245
257
$ asset_file = include FEEDZY_ABSPATH . '/build/onboarding/index.asset.php ' ;
246
258
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
259
wp_set_script_translations ( $ this ->plugin_name . '_on_boarding ' , 'feedzy-rss-feeds ' );
248
260
}
249
261
262
+ if ( 'feedzy_page_feedzy-settings ' === $ screen ->base ) {
263
+ $ this ->do_internal_page ( 'settings ' );
264
+ }
265
+
266
+ if ( 'feedzy_page_feedzy-integration ' === $ screen ->base ) {
267
+ $ this ->do_internal_page ( 'integrations ' );
268
+ }
269
+
270
+ if ( 'feedzy_categories ' === $ screen ->post_type ) {
271
+ $ this ->do_internal_page ( 'add ' === $ screen ->action ? 'new-category ' : 'categories ' );
272
+ }
273
+
250
274
if ( ! in_array ( $ screen ->base , $ upsell_screens , true ) && strpos ( $ screen ->id , 'feedzy ' ) === false ) {
251
275
return ;
252
276
}
253
277
254
278
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
255
279
if ( 'feedzy_page_feedzy-support ' === $ screen ->base && ( isset ( $ _GET ['tab ' ] ) && 'improve ' === $ _GET ['tab ' ] ) || ( 'edit ' !== $ screen ->base && 'feedzy_imports ' === $ screen ->post_type ) ) {
256
280
257
- $ this ->register_survey ();
258
-
259
281
$ asset_file = include FEEDZY_ABSPATH . '/build/feedback/index.asset.php ' ;
260
282
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
283
wp_enqueue_style ( 'wp-block-editor ' );
@@ -272,6 +294,17 @@ public function enqueue_styles_admin() {
272
294
wp_set_script_translations ( $ this ->plugin_name . '_feedback ' , 'feedzy-rss-feeds ' );
273
295
}
274
296
297
+ if ( 'feedzy_page_feedzy-support ' === $ screen ->base ) {
298
+ // phpcs:ignore WordPress.Security.NonceVerification.Recommended
299
+ $ tab = isset ( $ _GET ['tab ' ] ) ? sanitize_text_field ( wp_unslash ( $ _GET ['tab ' ] ) ) : '' ;
300
+ $ suffix = ! empty ( $ tab ) ? '- ' . $ tab : '' ;
301
+ $ this ->do_internal_page ( 'support ' . $ suffix );
302
+ }
303
+
304
+ if ( ( 'edit ' !== $ screen ->base && 'feedzy_imports ' === $ screen ->post_type ) ) {
305
+ $ this ->do_internal_page ( 'new-import ' );
306
+ }
307
+
275
308
if ( 'feedzy_imports ' === $ screen ->post_type && 'edit ' === $ screen ->base && feedzy_show_review_notice () ) {
276
309
$ asset_file = include FEEDZY_ABSPATH . '/build/review/index.asset.php ' ;
277
310
wp_enqueue_script ( $ this ->plugin_name . '_review ' , FEEDZY_ABSURL . 'build/review/index.js ' , $ asset_file ['dependencies ' ], $ asset_file ['version ' ], true );
@@ -2026,20 +2059,11 @@ public static function plan_category( $license_data ) {
2026
2059
* @return array
2027
2060
* @see survey.js
2028
2061
*/
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
-
2062
+ public function get_survey_data () {
2063
+ $ license_data = get_option ( 'feedzy_rss_feeds_pro_license_data ' , array () );
2040
2064
$ integration_status = $ this ->api_license_status ();
2041
2065
2042
- $ days_since_install = round ( ( time () - get_option ( 'feedzy_rss_feeds_install ' , 0 ) ) / DAY_IN_SECONDS );
2066
+ $ days_since_install = round ( ( time () - get_option ( 'feedzy_rss_feeds_install ' , time () ) ) / DAY_IN_SECONDS );
2043
2067
$ install_category = 0 ;
2044
2068
if ( 0 === $ days_since_install || 1 === $ days_since_install ) {
2045
2069
$ install_category = 0 ;
@@ -2053,45 +2077,30 @@ public function get_survery_metadata() {
2053
2077
$ install_category = 91 ;
2054
2078
}
2055
2079
2080
+ $ masked_key_license = null ;
2081
+ if ( isset ( $ license_data ->key ) ) {
2082
+ $ masked_key_license = str_repeat ( '* ' , strlen ( $ license_data ->key ) / 2 ) . substr ( $ license_data ->key , strlen ( $ license_data ->key ) / 2 );
2083
+ }
2084
+
2056
2085
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 ' ,
2086
+ 'environmentId ' => 'clskgehf78eu5podwdrnzciti ' ,
2087
+ 'apiHost ' => 'https://app.formbricks.com ' ,
2088
+ 'attributes ' => array (
2089
+ 'free_version ' => $ this ->version ,
2090
+ 'pro_version ' => defined ( 'FEEDZY_PRO_VERSION ' ) ? FEEDZY_PRO_VERSION : '' ,
2091
+ 'openai ' => $ integration_status ['openaiStatus ' ] ? 'valid ' : 'invalid ' ,
2092
+ 'amazon ' => $ integration_status ['amazonStatus ' ] ? 'valid ' : 'invalid ' ,
2093
+ 'spinnerchief ' => $ integration_status ['spinnerChiefStatus ' ] ? 'valid ' : 'invalid ' ,
2094
+ 'wordai ' => $ integration_status ['wordaiStatus ' ] ? 'valid ' : 'invalid ' ,
2095
+ 'plan ' => $ this ->plan_category ( $ license_data ),
2096
+ 'days_since_install ' => $ install_category ,
2097
+ 'install_days_number ' => $ days_since_install ,
2098
+ 'license_status ' => ! empty ( $ license_data ->license ) ? $ license_data ->license : 'invalid ' ,
2099
+ 'license_key ' => $ masked_key_license
2068
2100
),
2069
2101
);
2070
2102
}
2071
2103
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
2104
/**
2096
2105
* Add banner anchor for promotions.
2097
2106
*/
@@ -2332,4 +2341,11 @@ public function register_settings() {
2332
2341
)
2333
2342
);
2334
2343
}
2344
+
2345
+ /**
2346
+ * Mark the page as internal.
2347
+ */
2348
+ private function do_internal_page ( $ page_slug ) {
2349
+ do_action ( 'themeisle_internal_page ' , $ this ->plugin_name , $ page_slug );
2350
+ }
2335
2351
}
0 commit comments