Skip to content

Commit 3ae198b

Browse files
committed
better checks
1 parent d9b373e commit 3ae198b

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed
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' => '8c1516cb1a7ac8c4b6bb');
1+
<?php return array('dependencies' => array('lodash', 'react', 'react-jsx-runtime', 'wp-api-fetch', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '94249c2d819abb976e73');

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.

includes/LinkPrefetch/LinkPrefetch.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ class LinkPrefetch {
7575
public function __construct( Container $container ) {
7676
$this->container = $container;
7777

78-
$capabilities = new SiteCapabilities();
78+
$capabilities = ( new SiteCapabilities() )->all();
7979

80-
$this::$has_link_prefetch_click = $capabilities->get( 'hasLinkPrefetchClick' );
81-
$this::$has_link_prefetch_hover = $capabilities->get( 'hasLinkPrefetchHover' );
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;
8282

83-
if ( ! $this::$has_link_prefetch_click && ! $this::$has_link_prefetch_hover ) {
83+
if ( false === $this::$has_link_prefetch_click && false === $this::$has_link_prefetch_hover ) {
8484
delete_option( self::$option_name );
8585
return;
8686
}

src/components/App/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import '../../styles/styles.css';
44

55
// Newfold
66
import { Container, Root, Page, Title } from '@newfold/ui-component-library';
7-
import { NewfoldRuntime } from '@newfold/wp-module-runtime';
87

98
// WordPress
109
import { useEffect } from '@wordpress/element';
@@ -24,8 +23,10 @@ import getAppText from './getAppText';
2423
const App = () => {
2524

2625
const { title, description } = getAppText();
27-
const hasLinkPrefetchClick = NewfoldRuntime.hasCapability('hasLinkPrefetchClick');
28-
const hasLinkPrefetchHover = NewfoldRuntime.hasCapability('hasLinkPrefetchHover');
26+
const capabilities = NewfoldRuntime.capabilities || {};
27+
28+
const hasLinkPrefetchClick = capabilities.hasOwnProperty('hasLinkPrefetchClick') ? capabilities.hasLinkPrefetchClick : null;
29+
const hasLinkPrefetchHover = capabilities.hasOwnProperty('hasLinkPrefetchHover') ? capabilities.hasLinkPrefetchHover : null;
2930

3031
useEffect( () => {
3132
const brand = NewfoldRuntime.sdk?.plugin?.brand;
@@ -71,7 +72,7 @@ const App = () => {
7172
>
7273
<JetpackBoost />
7374
</Container.Block>
74-
{ ( hasLinkPrefetchClick || hasLinkPrefetchHover ) && (
75+
{ ( false !== hasLinkPrefetchClick && false !== hasLinkPrefetchHover ) && (
7576
<Container.Block
7677
separator
7778
className="newfold-link-prefetch"

0 commit comments

Comments
 (0)