@@ -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,50 +308,35 @@ 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
}
332
- }
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
+ 'install_days_number ' => $ install_days_number ,
331
+ 'version ' => RIVERBANK_VERSION ,
332
+ ),
333
+ );
333
334
334
- /**
335
- * Convert a number to a category.
336
- *
337
- * @param int $number Number to convert.
338
- * @param int $scale Scale.
339
- *
340
- * @return int
341
- */
342
- public static function convert_to_category ( $ number , $ scale = 1 ) {
343
- $ normalized_number = intval ( round ( $ number / $ scale ) );
344
-
345
- if ( 0 === $ normalized_number || 1 === $ normalized_number ) {
346
- return 0 ;
347
- } elseif ( $ normalized_number > 1 && $ normalized_number < 8 ) {
348
- return 7 ;
349
- } elseif ( $ normalized_number >= 8 && $ normalized_number < 31 ) {
350
- return 30 ;
351
- } elseif ( $ normalized_number > 30 && $ normalized_number < 90 ) {
352
- return 90 ;
353
- } elseif ( $ normalized_number > 90 ) {
354
- return 91 ;
355
- }
335
+ return $ data ;
336
+ },
337
+ 10 ,
338
+ 2
339
+ );
340
+ do_action ( 'themeisle_internal_page ' , RIVERBANK_PRODUCT_SLUG , $ screen ->id );
356
341
}
357
342
}
0 commit comments