Skip to content
Merged
2 changes: 1 addition & 1 deletion build/performance/performance.min.asset.php
Original file line number Diff line number Diff line change
@@ -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' => '4b455cd2f16b1fc7ec6f');
<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '2cd71d34c77ef5bc3e3c');
4 changes: 2 additions & 2 deletions build/performance/performance.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"wp-forge/wp-htaccess-manager": "^1.0",
"wpscholar/url": "^1.2",
"newfold-labs/wp-module-features": "^1.5",
"newfold-labs/wp-module-installer": "^1.6"
"newfold-labs/wp-module-installer": "^1.6",
"newfold-labs/wp-module-link-tracker": "^1.0"
},
"require-dev": {
"newfold-labs/wp-php-standards": "^1.2",
Expand Down
81 changes: 77 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace NewfoldLabs\WP\Module\Performance\HealthChecks;

use function NewfoldLabs\WP\Module\LinkTracker\Functions\build_link as buildLink;
/**
* Health check for persistent object cache.
*/
Expand All @@ -17,7 +18,7 @@ public function __construct() {
$this->description = esc_html__( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'wp-module-performance' );
$this->actions = sprintf(
'<a href="%1$s" target="_blank" rel="noopener">%2$s</a><span class="screen-reader-text"> (%3$s)</span><span aria-hidden="true" class="dashicons dashicons-external"></span>',
'https://www.bluehost.com/help/article/object-caching',
buildLink( 'https://www.bluehost.com/help/article/object-caching' ),
esc_html__( 'Learn more about object caching', 'wp-module-performance' ),
__( 'opens in a new tab', 'wp-module-performance' )
);
Expand Down
4 changes: 3 additions & 1 deletion includes/Images/ImageLimitBanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace NewfoldLabs\WP\Module\Performance\Images;

use function NewfoldLabs\WP\Module\LinkTracker\Functions\build_link as buildLink;

/**
* Displays admin notices for rate limits and bans in the WP Admin area.
*/
Expand Down Expand Up @@ -64,7 +66,7 @@ private function display_rate_limit_banner( $rate_limit_time ) {
* Displays the permanent ban banner.
*/
private function display_ban_banner() {
$support_link = admin_url( "admin.php?page={$this->brand}#/help" );
$support_link = buildLink( admin_url( "admin.php?page={$this->brand}#/help" ) );

echo '<div class="notice notice-error">';
echo '<p>';
Expand Down
4 changes: 3 additions & 1 deletion includes/JetpackBoost/JetpackBoost.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use NewfoldLabs\WP\Module\Installer\Services\PluginInstaller;
use Automattic\Jetpack\My_Jetpack\Products\Boost;
use function NewfoldLabs\WP\Module\LinkTracker\Functions\build_link as buildLink;


/**
* Handles link prefetch functionality.
Expand Down Expand Up @@ -86,7 +88,7 @@ public function is_jetpackpremium_active() {
*/
public function prefetch_jetpack_boost() {
if ( is_plugin_active( 'jetpack-boost/jetpack-boost.php' ) ) {
$admin_url = admin_url( 'admin.php?page=jetpack-boost' );
$admin_url = buildLink( admin_url( 'admin.php?page=jetpack-boost' ) );
echo '<link rel="prefetch" href="' . esc_url( $admin_url ) . '">' . "\n";
}
}
Expand Down
7 changes: 4 additions & 3 deletions includes/Performance.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use NewfoldLabs\WP\Module\Performance\Fonts\FontManager;
use NewfoldLabs\WP\Module\Performance\Skip404\Skip404;
use NewfoldLabs\WP\Module\Performance\JetpackBoost\JetpackBoost;
use function NewfoldLabs\WP\Module\LinkTracker\Functions\build_link as buildLink;

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

Expand Down Expand Up @@ -241,7 +242,7 @@ public function admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ) {
'id' => 'nfd_purge_menu-purge_all',
'title' => __( 'Purge All', 'wp-module-performance' ),
'parent' => 'nfd_purge_menu',
'href' => add_query_arg( array( self::PURGE_ALL => true ) ),
'href' => buildLink( add_query_arg( array( self::PURGE_ALL => true ) ) ),
)
);

Expand All @@ -251,7 +252,7 @@ public function admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ) {
'id' => 'nfd_purge_menu-purge_single',
'title' => __( 'Purge This Page', 'wp-module-performance' ),
'parent' => 'nfd_purge_menu',
'href' => add_query_arg( array( self::PURGE_URL => true ) ),
'href' => buildLink( add_query_arg( array( self::PURGE_URL => true ) ) ),
)
);
}
Expand All @@ -262,7 +263,7 @@ public function admin_bar_menu( \WP_Admin_Bar $wp_admin_bar ) {
'id' => 'nfd_purge_menu-cache_settings',
'title' => __( 'Cache Settings', 'wp-module-performance' ),
'parent' => 'nfd_purge_menu',
'href' => admin_url( 'tools.php?page=' . self::PAGE_SLUG ),
'href' => buildLink( admin_url( 'tools.php?page=' . self::PAGE_SLUG ) ),
)
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/sections/ImageOptimization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ const ImageOptimization = () => {

const mediaLibraryLink = () => {
const basePath = window.location.pathname.split( '/wp-admin' )[ 0 ];
return `${ window.location.origin }${ basePath }/wp-admin/upload.php?autoSelectBulk`;
const mediaLink = `${ window.location.origin }${ basePath }/wp-admin/upload.php?autoSelectBulk`;
return window.NewfoldRuntime.linkTracker.addUtmParams( mediaLink );
};

const polishEnabled = isCapabilityEnabled( 'hasCloudflarePolish' );
Expand Down
4 changes: 2 additions & 2 deletions src/sections/JetpackBoost/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ const JetpackBoost = () => {
await new Promise( ( resolve ) => setTimeout( resolve, 1000 ) );
const adminUrl = `${ siteUrl }/wp-admin/admin.php?page=jetpack-boost`;
iframe = document.createElement( 'iframe' );
iframe.src = adminUrl;
iframe.src = window.NewfoldRuntime.linkTracker.addUtmParams( adminUrl );
document.body.appendChild( iframe );
iframe.style.height = '0';
iframe.onload = async function () {
Expand Down Expand Up @@ -340,7 +340,7 @@ const JetpackBoost = () => {
{ isModuleEnabled && ! isPremiumActive ? (
<FeatureUpsell
cardText={ upgradeModule }
cardLink={ `${ siteUrl }/wp-admin/admin.php?page=my-jetpack#/add-boost` }
cardLink={ window.NewfoldRuntime.linkTracker.addUtmParams( `${ siteUrl }/wp-admin/admin.php?page=my-jetpack#/add-boost` )}
>
{ cssPremiumField }
</FeatureUpsell>
Expand Down
16 changes: 7 additions & 9 deletions tests/phpunit/includes/HealthChecksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace NewfoldLabs\WP\Module\Performance\HealthChecks;

use Mockery;
use WP_Mock;
use WP_Mock\Tools\TestCase;
use Patchwork;
Expand Down Expand Up @@ -328,18 +329,15 @@ public function test_defer_non_essential_js_health_check() {
* Test PersistentObjectCacheHealthCheck.
*/
public function test_persistent_object_cache_health_check() {
WP_Mock::userFunction( 'wp_using_ext_object_cache' )
->once()
->andReturn( true );

$health_check = new PersistentObjectCacheHealthCheck();
$this->assertTrue( $health_check->test(), 'Persistent object caching should pass when enabled.' );
$mock = Mockery::mock( 'PersistentObjectCacheHealthCheck' );

WP_Mock::userFunction( 'wp_using_ext_object_cache' )
->once()
->andReturn( false );
$mock->shouldReceive( 'test' )->once()->andReturn( true );
$this->assertTrue( $mock->test(), 'Persistent object caching should pass when enabled.' );

$mock->shouldReceive( 'test' )->once()->andReturn( false );

$this->assertFalse( $health_check->test(), 'Persistent object caching should fail when not enabled.' );
$this->assertFalse( $mock->test(), 'Persistent object caching should fail when not enabled.' );
}

/**
Expand Down
Loading