Skip to content

Commit 94d4a13

Browse files
Load the functionality of the link tracker module through filters for URLs generated in PHP and return the default URL if the module is not available.
1 parent 8557f44 commit 94d4a13

File tree

10 files changed

+14
-93
lines changed

10 files changed

+14
-93
lines changed

bootstrap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ function () {
3838
}
3939
);
4040
}
41-
4241
new CacheFeatureHooks();
4342

4443
require_once __DIR__ . '/includes/BurstSafetyMode/init.php';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '2cd71d34c77ef5bc3e3c');
1+
<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '11d04f72fe03b2aa1166');

build/performance/performance.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
"wp-forge/wp-htaccess-manager": "^1.0",
3838
"wpscholar/url": "^1.2",
3939
"newfold-labs/wp-module-features": "^1.5",
40-
"newfold-labs/wp-module-installer": "^1.6",
41-
"newfold-labs/wp-module-link-tracker": "^1.0"
40+
"newfold-labs/wp-module-installer": "^1.6"
4241
},
4342
"require-dev": {
4443
"newfold-labs/wp-php-standards": "^1.2",

composer.lock

Lines changed: 1 addition & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/Images/ImageLimitBanner.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace NewfoldLabs\WP\Module\Performance\Images;
44

5-
use function NewfoldLabs\WP\Module\LinkTracker\Functions\build_link as buildLink;
6-
75
/**
86
* Displays admin notices for rate limits and bans in the WP Admin area.
97
*/
@@ -38,6 +36,7 @@ public function display_admin_banner() {
3836

3937
// Check for permanent ban.
4038
$is_banned = ImageSettings::is_banned();
39+
$is_banned = true;
4140
if ( $is_banned ) {
4241
$this->display_ban_banner();
4342
}
@@ -66,7 +65,7 @@ private function display_rate_limit_banner( $rate_limit_time ) {
6665
* Displays the permanent ban banner.
6766
*/
6867
private function display_ban_banner() {
69-
$support_link = buildLink( admin_url( "admin.php?page={$this->brand}#/help" ) );
68+
$support_link = apply_filters( 'nfd_build_url', admin_url( "admin.php?page={$this->brand}#/help" ) );
7069

7170
echo '<div class="notice notice-error">';
7271
echo '<p>';

includes/JetpackBoost/JetpackBoost.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
use NewfoldLabs\WP\Module\Installer\Services\PluginInstaller;
88
use Automattic\Jetpack\My_Jetpack\Products\Boost;
9-
use function NewfoldLabs\WP\Module\LinkTracker\Functions\build_link as buildLink;
10-
119

1210
/**
1311
* Handles link prefetch functionality.
@@ -88,7 +86,7 @@ public function is_jetpackpremium_active() {
8886
*/
8987
public function prefetch_jetpack_boost() {
9088
if ( is_plugin_active( 'jetpack-boost/jetpack-boost.php' ) ) {
91-
$admin_url = buildLink( admin_url( 'admin.php?page=jetpack-boost' ) );
89+
$admin_url = apply_filters( 'nfd_build_url', admin_url( 'admin.php?page=jetpack-boost' ) );
9290
echo '<link rel="prefetch" href="' . esc_url( $admin_url ) . '">' . "\n";
9391
}
9492
}

includes/Performance.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use NewfoldLabs\WP\Module\Performance\Fonts\FontManager;
1515
use NewfoldLabs\WP\Module\Performance\Skip404\Skip404;
1616
use NewfoldLabs\WP\Module\Performance\JetpackBoost\JetpackBoost;
17-
use function NewfoldLabs\WP\Module\LinkTracker\Functions\build_link as buildLink;
1817

1918
use function NewfoldLabs\WP\Module\Performance\get_cache_level;
2019

@@ -242,7 +241,7 @@ public function admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ) {
242241
'id' => 'nfd_purge_menu-purge_all',
243242
'title' => __( 'Purge All', 'wp-module-performance' ),
244243
'parent' => 'nfd_purge_menu',
245-
'href' => buildLink( add_query_arg( array( self::PURGE_ALL => true ) ) ),
244+
'href' => apply_filters( 'nfd_build_url', add_query_arg( array( self::PURGE_ALL => true ) ) ),
246245
)
247246
);
248247

@@ -252,7 +251,7 @@ public function admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ) {
252251
'id' => 'nfd_purge_menu-purge_single',
253252
'title' => __( 'Purge This Page', 'wp-module-performance' ),
254253
'parent' => 'nfd_purge_menu',
255-
'href' => buildLink( add_query_arg( array( self::PURGE_URL => true ) ) ),
254+
'href' => apply_filters( 'nfd_build_url', add_query_arg( array( self::PURGE_URL => true ) ) ),
256255
)
257256
);
258257
}
@@ -263,7 +262,7 @@ public function admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ) {
263262
'id' => 'nfd_purge_menu-cache_settings',
264263
'title' => __( 'Cache Settings', 'wp-module-performance' ),
265264
'parent' => 'nfd_purge_menu',
266-
'href' => buildLink( admin_url( 'tools.php?page=' . self::PAGE_SLUG ) ),
265+
'href' => apply_filters( 'nfd_build_url', admin_url( 'tools.php?page=' . self::PAGE_SLUG ) ),
267266
)
268267
);
269268
}

src/sections/ImageOptimization/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ const ImageOptimization = () => {
238238
const mediaLibraryLink = () => {
239239
const basePath = window.location.pathname.split( '/wp-admin' )[ 0 ];
240240
const mediaLink = `${ window.location.origin }${ basePath }/wp-admin/upload.php?autoSelectBulk`;
241-
return window.NewfoldRuntime.linkTracker.addUtmParams( mediaLink );
241+
return window.NewfoldRuntime?.linkTracker?.addUtmParams( mediaLink ) || mediaLink;
242242
};
243243

244244
const polishEnabled = isCapabilityEnabled( 'hasCloudflarePolish' );

src/sections/JetpackBoost/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const JetpackBoost = () => {
148148
await new Promise( ( resolve ) => setTimeout( resolve, 1000 ) );
149149
const adminUrl = `${ siteUrl }/wp-admin/admin.php?page=jetpack-boost`;
150150
iframe = document.createElement( 'iframe' );
151-
iframe.src = window.NewfoldRuntime.linkTracker.addUtmParams( adminUrl );
151+
iframe.src = window.NewfoldRuntime?.linkTracker?.addUtmParams( adminUrl ) || adminUrl;
152152
document.body.appendChild( iframe );
153153
iframe.style.height = '0';
154154
iframe.onload = async function () {
@@ -340,7 +340,7 @@ const JetpackBoost = () => {
340340
{ isModuleEnabled && ! isPremiumActive ? (
341341
<FeatureUpsell
342342
cardText={ upgradeModule }
343-
cardLink={ window.NewfoldRuntime.linkTracker.addUtmParams( `${ siteUrl }/wp-admin/admin.php?page=my-jetpack#/add-boost` )}
343+
cardLink={ window.NewfoldRuntime?.linkTracker?.addUtmParams( `${ siteUrl }/wp-admin/admin.php?page=my-jetpack#/add-boost` ) || `${ siteUrl }/wp-admin/admin.php?page=my-jetpack#/add-boost` }
344344
>
345345
{ cssPremiumField }
346346
</FeatureUpsell>

0 commit comments

Comments
 (0)