@@ -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,50 +380,35 @@ 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
}
404
- }
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
+ 'install_days_number ' => $ install_days_number ,
403
+ 'version ' => RAFT_VERSION ,
404
+ ),
405
+ );
405
406
406
- /**
407
- * Convert a number to a category.
408
- *
409
- * @param int $number Number to convert.
410
- * @param int $scale Scale.
411
- *
412
- * @return int
413
- */
414
- public static function convert_to_category ( $ number , $ scale = 1 ) {
415
- $ normalized_number = intval ( round ( $ number / $ scale ) );
416
-
417
- if ( 0 === $ normalized_number || 1 === $ normalized_number ) {
418
- return 0 ;
419
- } elseif ( $ normalized_number > 1 && $ normalized_number < 8 ) {
420
- return 7 ;
421
- } elseif ( $ normalized_number >= 8 && $ normalized_number < 31 ) {
422
- return 30 ;
423
- } elseif ( $ normalized_number > 30 && $ normalized_number < 90 ) {
424
- return 90 ;
425
- } elseif ( $ normalized_number > 90 ) {
426
- return 91 ;
427
- }
407
+ return $ data ;
408
+ },
409
+ 10 ,
410
+ 2
411
+ );
412
+ do_action ( 'themeisle_internal_page ' , RAFT_PRODUCT_SLUG , $ screen ->id );
428
413
}
429
414
}
0 commit comments