Skip to content

Commit 1fbd61e

Browse files
authored
Merge pull request #825 from newfold-labs/add/link-tracker
Implement wp-module-link-tracker features across different URLs
2 parents 457ffc1 + f8c39ca commit 1fbd61e

File tree

7 files changed

+24
-14
lines changed

7 files changed

+24
-14
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-core-data', 'wp-data', 'wp-deprecated', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-preferences', 'wp-primitives'), 'version' => '9cb31ccae1cdbcf503b0');
1+
<?php return array(
2+
'dependencies' => array( 'react-jsx-runtime', 'wp-api-fetch', 'wp-blob', 'wp-block-editor', 'wp-components', 'wp-core-data', 'wp-data', 'wp-deprecated', 'wp-dom-ready', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-plugins', 'wp-preferences', 'wp-primitives' ),
3+
'version' => '9cb31ccae1cdbcf503b0',
4+
);
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<?php return array('dependencies' => array(), 'version' => 'd409f6c052e3b64374b3');
1+
<?php return array(
2+
'dependencies' => array(),
3+
'version' => 'd409f6c052e3b64374b3',
4+
);
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<?php return array('dependencies' => array(), 'version' => '857c9b1be7fae2d05356');
1+
<?php return array(
2+
'dependencies' => array(),
3+
'version' => '857c9b1be7fae2d05356',
4+
);

includes/LoginRedirect.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function filter_redirect( $original_redirect, $user ) {
6161
if ( '0' === $redirect_option ) {
6262
return $original_redirect;
6363
} elseif ( '1' === $redirect_option ) {
64-
return admin_url( '/index.php?page=' . WP_Admin::$slug );
64+
return apply_filters( 'nfd_build_url', admin_url( '/index.php?page=' . WP_Admin::$slug ) );
6565
}
6666

6767
// Don't redirect to onboarding if onboarding was exited or completed.
@@ -81,7 +81,7 @@ public static function filter_redirect( $original_redirect, $user ) {
8181
}
8282

8383
// Redirect to onboarding
84-
return admin_url( '/index.php?page=' . WP_Admin::$slug );
84+
return apply_filters( 'nfd_build_url', admin_url( '/index.php?page=' . WP_Admin::$slug ) );
8585
}
8686

8787
/**

includes/WP_Admin.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public static function render() {
211211
echo PHP_EOL;
212212
echo '<!-- NFD:ONBOARDING -->';
213213
echo PHP_EOL;
214-
echo '<div id="nfd-onboarding" class="nfd-onboarding-container">' . self::is_loading() . '</div>';
214+
echo '<div id="nfd-onboarding" class="nfd-onboarding-container">' . self::is_loading() . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
215215
echo PHP_EOL;
216216
echo '<!-- /NFD:ONBOARDING -->';
217217
echo PHP_EOL;
@@ -246,14 +246,14 @@ public static function register_assets() {
246246
NFD_ONBOARDING_DIR . '/languages'
247247
);
248248

249-
$nfdOnboardingData = array(
249+
$nfd_onboarding_data = array(
250250
'runtime' => Data::runtime(),
251251
'input' => ReduxStateService::get( 'input' ),
252252
'sitegen' => ReduxStateService::get( 'sitegen' ),
253253
);
254254
\wp_add_inline_script(
255255
self::$slug,
256-
'var nfdOnboarding =' . wp_json_encode( $nfdOnboardingData ) . ';',
256+
'var nfdOnboarding =' . wp_json_encode( $nfd_onboarding_data ) . ';',
257257
'before'
258258
);
259259

@@ -331,12 +331,12 @@ public static function exit_to_dashboard(): bool {
331331

332332
// If the brand plugin page URL is not found in the runtime, redirect to the WordPress admin.
333333
if ( empty( $brand_plugin_url ) ) {
334-
wp_redirect( admin_url() . '?' . $dashboard_redirect_params );
334+
wp_redirect( apply_filters( 'nfd_build_url', admin_url() . '?' . $dashboard_redirect_params ) );
335335
exit;
336336
}
337337

338338
// If the brand plugin page URL is found in the runtime, redirect to the brand plugin page.
339-
wp_redirect( $brand_plugin_url . '&' . $dashboard_redirect_params );
339+
wp_redirect( apply_filters( 'nfd_build_url', $brand_plugin_url . '&' . $dashboard_redirect_params ) );
340340
exit;
341341
}
342342

@@ -455,7 +455,7 @@ public static function can_restart_onboarding(): void {
455455
'var nfdOnboardingRestartMeta =' . wp_json_encode(
456456
array(
457457
'buttonText' => \__( 'Build with AI', 'wp-module-onboarding' ),
458-
'buttonHref' => \admin_url( 'index.php?page=' . self::$slug ),
458+
'buttonHref' => \apply_filters( 'nfd_build_url', admin_url( 'index.php?page=' . self::$slug ) ),
459459
)
460460
) . ';',
461461
'before'
@@ -504,7 +504,7 @@ public static function hide_onboarding_restart_card(): void {
504504
\wp_enqueue_style( 'hide-onboarding-restart-card' );
505505
}
506506

507-
/*
507+
/**
508508
Enqueue site editor specific assets when coming from onboarding.
509509
*
510510
* @return void

src/app/data/store/slices/runtime.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export const selectors = {
9393
const migrationUrl =
9494
addQueryArgs( migrationInfo?.defaultLink, migrationInfo?.queryParams ) +
9595
( migrationInfo?.fragment || '' );
96-
return migrationUrl;
96+
return window?.NewfoldRuntime?.linkTracker?.addUtmParams( migrationUrl ) || migrationUrl;
9797
},
9898

9999
/**

src/app/steps/Migration/MigrationStep.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const MigrationStep = () => {
2525

2626
/**
2727
* Track migration initiated event
28+
*
2829
* @param { string } instaWpMigrationUrl The migration url
2930
* @return { Promise<void> }
3031
*/
@@ -70,7 +71,7 @@ const MigrationStep = () => {
7071
await trackMigrationInitiatedEvent( migrateUrl );
7172

7273
// Open migration url (external)
73-
window.open( migrateUrl, '_self' );
74+
window.open( window?.NewfoldRuntime?.linkTracker?.addUtmParams( migrateUrl ) || migrateUrl, '_self' );
7475
} else {
7576
throw new Error( 'Failed to fetch migration url' );
7677
}

0 commit comments

Comments
 (0)