@@ -33,7 +33,7 @@ public function setup_admin_hooks() {
33
33
add_action ( 'wp_ajax_raft_dismiss_welcome_notice ' , array ( $ this , 'remove_welcome_notice ' ) );
34
34
add_action ( 'wp_ajax_raft_set_otter_ref ' , array ( $ this , 'set_otter_ref ' ) );
35
35
add_action ( 'activated_plugin ' , array ( $ this , 'after_otter_activation ' ) );
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_raft_dismiss_design_pack_notice ' , array ( $ this , 'remove_design_pack_notice ' ) );
@@ -380,27 +380,37 @@ public function after_otter_activation( $plugin ) {
380
380
}
381
381
382
382
/**
383
- * Add NPS form .
383
+ * Register internal pages .
384
384
*
385
385
* @return void
386
386
*/
387
- public function add_nps_form () {
387
+ public function register_internal_page () {
388
388
$ screen = get_current_screen ();
389
-
390
- if ( current_user_can ( 'manage_options ' ) && ( 'dashboard ' === $ screen ->id || 'themes ' === $ screen ->id ) ) {
391
- $ website_url = preg_replace ( '/[^a-zA-Z0-9]+/ ' , '' , get_site_url () );
392
-
393
- $ config = array (
394
- 'environmentId ' => 'clp9hp3j71oqndl2ietgq8nej ' ,
395
- 'apiHost ' => 'https://app.formbricks.com ' ,
396
- 'userId ' => 'raft_ ' . $ website_url ,
397
- 'attributes ' => array (
398
- 'days_since_install ' => self ::convert_to_category ( round ( ( time () - get_option ( 'raft_install ' , time () ) ) / DAY_IN_SECONDS ) ),
399
- ),
400
- );
401
-
402
- 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> ' ;
389
+
390
+ if ( ! current_user_can ( 'manage_options ' ) || ( 'dashboard ' !== $ screen ->id && 'themes ' !== $ screen ->id ) ) {
391
+ return ;
403
392
}
393
+
394
+ add_filter (
395
+ 'themeisle-sdk/survey/ ' . RAFT_PRODUCT_SLUG ,
396
+ function ( $ data , $ page_slug ) {
397
+ $ install_days_number = intval ( ( time () - get_option ( 'raft_install ' , time () ) ) / DAY_IN_SECONDS );
398
+
399
+ $ data = array (
400
+ 'environmentId ' => 'clp9hp3j71oqndl2ietgq8nej ' ,
401
+ 'attributes ' => array (
402
+ 'days_since_install ' => self ::convert_to_category ( $ install_days_number ),
403
+ 'install_days_number ' => $ install_days_number ,
404
+ 'version ' => RAFT_VERSION ,
405
+ ),
406
+ );
407
+
408
+ return $ data ;
409
+ },
410
+ 10 ,
411
+ 2
412
+ );
413
+ do_action ( 'themeisle_internal_page ' , RAFT_PRODUCT_SLUG , $ screen ->id );
404
414
}
405
415
406
416
/**
0 commit comments