@@ -33,7 +33,7 @@ public function setup_admin_hooks() {
3333 add_action ( 'admin_notices ' , array ( $ this , 'render_welcome_notice ' ), 0 );
3434 add_action ( 'wp_ajax_fork_dismiss_welcome_notice ' , array ( $ this , 'remove_welcome_notice ' ) );
3535 add_action ( 'wp_ajax_fork_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 ' ) );
3737
3838 add_action ( 'enqueue_block_editor_assets ' , array ( $ this , 'add_fse_design_pack_notice ' ) );
3939 add_action ( 'wp_ajax_fork_dismiss_design_pack_notice ' , array ( $ this , 'remove_design_pack_notice ' ) );
@@ -307,27 +307,37 @@ private function get_otter_status(): string {
307307 }
308308
309309 /**
310- * Add NPS form .
310+ * Register internal pages .
311311 *
312312 * @return void
313313 */
314- public function add_nps_form () {
314+ public function register_internal_page () {
315315 $ screen = get_current_screen ();
316-
317- if ( current_user_can ( 'manage_options ' ) && ( 'dashboard ' === $ screen ->id || 'themes ' === $ screen ->id ) ) {
318- $ website_url = preg_replace ( '/[^a-zA-Z0-9]+/ ' , '' , get_site_url () );
319-
320- $ config = array (
321- 'environmentId ' => 'clr7hsvmjeu0u8up04ydg210b ' ,
322- 'apiHost ' => 'https://app.formbricks.com ' ,
323- 'userId ' => 'fork_ ' . $ website_url ,
324- 'attributes ' => array (
325- 'days_since_install ' => self ::convert_to_category ( round ( ( time () - get_option ( 'fork_install ' , time () ) ) / DAY_IN_SECONDS ) ),
326- ),
327- );
328-
329- 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> ' ;
316+
317+ if ( ! current_user_can ( 'manage_options ' ) || ( 'dashboard ' !== $ screen ->id && 'themes ' !== $ screen ->id ) ) {
318+ return ;
330319 }
320+
321+ add_filter (
322+ 'themeisle-sdk/survey/ ' . FORK_PRODUCT_SLUG ,
323+ function ( $ data , $ page_slug ) {
324+ $ install_days_number = intval ( ( time () - get_option ( 'fork_install ' , time () ) ) / DAY_IN_SECONDS );
325+
326+ $ data = array (
327+ 'environmentId ' => 'clr7hsvmjeu0u8up04ydg210b ' ,
328+ 'attributes ' => array (
329+ 'days_since_install ' => self ::convert_to_category ( $ install_days_number ),
330+ 'install_days_number ' => $ install_days_number ,
331+ 'version ' => FORK_VERSION ,
332+ ),
333+ );
334+
335+ return $ data ;
336+ },
337+ 10 ,
338+ 2
339+ );
340+ do_action ( 'themeisle_internal_page ' , FORK_PRODUCT_SLUG , $ screen ->id );
331341 }
332342
333343 /**
0 commit comments