@@ -33,7 +33,7 @@ public function setup_admin_hooks() {
33
33
add_action ( 'admin_notices ' , array ( $ this , 'render_welcome_notice ' ), 0 );
34
34
add_action ( 'wp_ajax_riverbank_dismiss_welcome_notice ' , array ( $ this , 'remove_welcome_notice ' ) );
35
35
add_action ( 'wp_ajax_riverbank_set_otter_ref ' , array ( $ this , 'set_otter_ref ' ) );
36
- add_action ( 'admin_print_scripts ' , array ( $ this , 'add_nps_form ' ) );
36
+ add_action ( 'admin_enqueue_scripts ' , array ( $ this , 'register_internal_page ' ) );
37
37
38
38
add_action ( 'enqueue_block_editor_assets ' , array ( $ this , 'add_fse_design_pack_notice ' ) );
39
39
add_action ( 'wp_ajax_riverbank_dismiss_design_pack_notice ' , array ( $ this , 'remove_design_pack_notice ' ) );
@@ -308,27 +308,37 @@ private function get_otter_status(): string {
308
308
}
309
309
310
310
/**
311
- * Add NPS form .
311
+ * Register internal pages .
312
312
*
313
313
* @return void
314
314
*/
315
- public function add_nps_form () {
315
+ public function register_internal_page () {
316
316
$ screen = get_current_screen ();
317
-
318
- if ( current_user_can ( 'manage_options ' ) && ( 'dashboard ' === $ screen ->id || 'themes ' === $ screen ->id ) ) {
319
- $ website_url = preg_replace ( '/[^a-zA-Z0-9]+/ ' , '' , get_site_url () );
320
-
321
- $ config = array (
322
- 'environmentId ' => 'clr7jal6eexcy8up0wdufqz2d ' ,
323
- 'apiHost ' => 'https://app.formbricks.com ' ,
324
- 'userId ' => 'riverbank_ ' . $ website_url ,
325
- 'attributes ' => array (
326
- 'days_since_install ' => self ::convert_to_category ( round ( ( time () - get_option ( 'riverbank_install ' , time () ) ) / DAY_IN_SECONDS ) ),
327
- ),
328
- );
329
-
330
- echo '<script type="text/javascript">!function(){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://unpkg.com/@formbricks/js@^1.6.5/dist/index.umd.js";var e=document.getElementsByTagName("script")[0];e.parentNode.insertBefore(t,e),setTimeout(function(){window.formbricks.init( ' . wp_json_encode ( $ config ) . ')},500)}();</script> ' ;
317
+
318
+ if ( ! current_user_can ( 'manage_options ' ) || ( 'dashboard ' !== $ screen ->id && 'themes ' !== $ screen ->id ) ) {
319
+ return ;
331
320
}
321
+
322
+ add_filter (
323
+ 'themeisle-sdk/survey/ ' . RIVERBANK_PRODUCT_SLUG ,
324
+ function ( $ data , $ page_slug ) {
325
+ $ install_days_number = intval ( ( time () - get_option ( 'riverbank_install ' , time () ) ) / DAY_IN_SECONDS );
326
+
327
+ $ data = array (
328
+ 'environmentId ' => 'clr7jal6eexcy8up0wdufqz2d ' ,
329
+ 'attributes ' => array (
330
+ 'days_since_install ' => self ::convert_to_category ( $ install_days_number ),
331
+ 'install_days_number ' => $ install_days_number ,
332
+ 'version ' => RIVERBANK_VERSION ,
333
+ ),
334
+ );
335
+
336
+ return $ data ;
337
+ },
338
+ 10 ,
339
+ 2
340
+ );
341
+ do_action ( 'themeisle_internal_page ' , RIVERBANK_PRODUCT_SLUG , $ screen ->id );
332
342
}
333
343
334
344
/**
0 commit comments