Skip to content

Commit 40024d3

Browse files
committed
Merge branch 'main' of https://github.com/newfold-labs/wp-module-performance into enhance/cloudflare-images-features
2 parents 39718fc + 30f5dcc commit 40024d3

File tree

14 files changed

+398
-271
lines changed

14 files changed

+398
-271
lines changed

.github/workflows/codecoverage-main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
path: gh-pages
7272

7373
- name: Install PHP
74-
uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
74+
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
7575
with:
7676
php-version: ${{ matrix.php }}
7777
coverage: xdebug
@@ -148,7 +148,7 @@ jobs:
148148

149149
- name: Commit code coverage to gh-pages
150150
if: ${{ matrix.php == '7.3' }}
151-
uses: stefanzweifel/git-auto-commit-action@e348103e9026cc0eee72ae06630dbe30c8bf7a79 # v5.1.0
151+
uses: stefanzweifel/git-auto-commit-action@778341af668090896ca464160c2def5d1d1a3eb0 # v6.0.1
152152
with:
153153
repository: gh-pages
154154
branch: gh-pages

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2727

2828
- name: Setup PHP
29-
uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0
29+
uses: shivammathur/setup-php@0f7f1d08e3e32076e51cae65eb0b0c871405b16e # v2.34.1
3030
with:
3131
php-version: '8.2'
3232
coverage: none

build/performance/performance-rtl.css

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

build/performance/performance.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
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' => '126efbd4b855c1411ec8');
1+
<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '906dd8d951c808fd986e');

build/performance/performance.min.css

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

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"wp-cli/wp-cli-bundle": "^2.8.1|^2.12",
4545
"wp-cli/i18n-command": "^2.6",
4646
"10up/wp_mock": "^0.5.0|^1.0.0",
47-
"johnpbloch/wordpress": "6.1.7",
47+
"johnpbloch/wordpress": "6.8.1",
4848
"lucatume/wp-browser": "*",
4949
"phpunit/phpcov": "*"
5050
},

composer.lock

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

includes/LinkPrefetch/LinkPrefetch.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

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

5+
use NewfoldLabs\WP\Module\Data\SiteCapabilities;
56
use NewfoldLabs\WP\ModuleLoader\Container;
67

78
/**
@@ -37,6 +38,20 @@ class LinkPrefetch {
3738
*/
3839
public static $option_name = 'nfd_link_prefetch_settings';
3940

41+
/**
42+
* Site capabilities for link prefetch Click.
43+
*
44+
* @var bool
45+
*/
46+
public static $has_link_prefetch_click = false;
47+
48+
/**
49+
* Site capabilities for link prefetch Hover.
50+
*
51+
* @var bool
52+
*/
53+
public static $has_link_prefetch_hover = false;
54+
4055
/**
4156
* Default settings.
4257
*
@@ -59,6 +74,17 @@ class LinkPrefetch {
5974
*/
6075
public function __construct( Container $container ) {
6176
$this->container = $container;
77+
78+
$capabilities = ( new SiteCapabilities() )->all();
79+
80+
$this::$has_link_prefetch_click = array_key_exists( 'hasLinkPrefetchClick', $capabilities ) ? $capabilities['hasLinkPrefetchClick'] : null;
81+
$this::$has_link_prefetch_hover = array_key_exists( 'hasLinkPrefetchHover', $capabilities ) ? $capabilities['hasLinkPrefetchHover'] : null;
82+
83+
if ( false === $this::$has_link_prefetch_click && false === $this::$has_link_prefetch_hover ) {
84+
delete_option( self::$option_name );
85+
return;
86+
}
87+
6288
add_filter( 'newfold-runtime', array( $this, 'add_to_runtime' ) );
6389
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
6490
if ( ! is_admin() ) {
@@ -74,6 +100,9 @@ public function __construct( Container $container ) {
74100
* @return array Modified runtime object.
75101
*/
76102
public function add_to_runtime( $sdk ) {
103+
104+
self::$default_settings['behavior'] = $this::$has_link_prefetch_click && $this::$has_link_prefetch_hover ? 'mouseHover' : 'mouseDown';
105+
77106
$values = array(
78107
'settings' => get_option( self::$option_name, self::$default_settings ),
79108
);

0 commit comments

Comments
 (0)