Skip to content

Implement wp-module-link-tracker features across different URLs #825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion build/3.1.0/onboarding-design-studio.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<?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');
<?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',
);
5 changes: 4 additions & 1 deletion build/3.1.0/onboarding-restart-button.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<?php return array('dependencies' => array(), 'version' => 'd409f6c052e3b64374b3');
<?php return array(
'dependencies' => array(),
'version' => 'd409f6c052e3b64374b3',
);
5 changes: 4 additions & 1 deletion build/3.1.0/sitegen-theme-marker.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
<?php return array('dependencies' => array(), 'version' => '857c9b1be7fae2d05356');
<?php return array(
'dependencies' => array(),
'version' => '857c9b1be7fae2d05356',
);
4 changes: 2 additions & 2 deletions includes/LoginRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function filter_redirect( $original_redirect, $user ) {
if ( '0' === $redirect_option ) {
return $original_redirect;
} elseif ( '1' === $redirect_option ) {
return admin_url( '/index.php?page=' . WP_Admin::$slug );
return apply_filters( 'nfd_build_url', admin_url( '/index.php?page=' . WP_Admin::$slug ) );
}

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

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

/**
Expand Down
14 changes: 7 additions & 7 deletions includes/WP_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public static function render() {
echo PHP_EOL;
echo '<!-- NFD:ONBOARDING -->';
echo PHP_EOL;
echo '<div id="nfd-onboarding" class="nfd-onboarding-container">' . self::is_loading() . '</div>';
echo '<div id="nfd-onboarding" class="nfd-onboarding-container">' . self::is_loading() . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo PHP_EOL;
echo '<!-- /NFD:ONBOARDING -->';
echo PHP_EOL;
Expand Down Expand Up @@ -246,14 +246,14 @@ public static function register_assets() {
NFD_ONBOARDING_DIR . '/languages'
);

$nfdOnboardingData = array(
$nfd_onboarding_data = array(
'runtime' => Data::runtime(),
'input' => ReduxStateService::get( 'input' ),
'sitegen' => ReduxStateService::get( 'sitegen' ),
);
\wp_add_inline_script(
self::$slug,
'var nfdOnboarding =' . wp_json_encode( $nfdOnboardingData ) . ';',
'var nfdOnboarding =' . wp_json_encode( $nfd_onboarding_data ) . ';',
'before'
);

Expand Down Expand Up @@ -331,12 +331,12 @@ public static function exit_to_dashboard(): bool {

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

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

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

/*
/**
Enqueue site editor specific assets when coming from onboarding.
*
* @return void
Expand Down
2 changes: 1 addition & 1 deletion src/app/data/store/slices/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const selectors = {
const migrationUrl =
addQueryArgs( migrationInfo?.defaultLink, migrationInfo?.queryParams ) +
( migrationInfo?.fragment || '' );
return migrationUrl;
return window?.NewfoldRuntime?.linkTracker?.addUtmParams( migrationUrl ) || migrationUrl;
},

/**
Expand Down
3 changes: 2 additions & 1 deletion src/app/steps/Migration/MigrationStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const MigrationStep = () => {

/**
* Track migration initiated event
*
* @param { string } instaWpMigrationUrl The migration url
* @return { Promise<void> }
*/
Expand Down Expand Up @@ -70,7 +71,7 @@ const MigrationStep = () => {
await trackMigrationInitiatedEvent( migrateUrl );

// Open migration url (external)
window.open( migrateUrl, '_self' );
window.open( window?.NewfoldRuntime?.linkTracker?.addUtmParams( migrateUrl ) || migrateUrl, '_self' );
} else {
throw new Error( 'Failed to fetch migration url' );
}
Expand Down
Loading