Skip to content
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

Release 2.1.0 #37

Merged
merged 72 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
c28ad8d
added link prefetch options component, LinkPrefetch class and js for …
geckod22 Oct 23, 2024
03256c3
added defer attribute to script tag
geckod22 Oct 25, 2024
4145534
phpcs on new class
geckod22 Oct 25, 2024
ba1198a
added copy text and changed toggle style
geckod22 Nov 4, 2024
3f90470
added restapi to manage the settings, adding bottom margin to fields
geckod22 Nov 4, 2024
f7801ae
New branch Jetpack Boost
Nov 4, 2024
fbf0991
Fix: phpcs
Nov 5, 2024
fe39f82
removed console.log
geckod22 Nov 7, 2024
3236585
Tweak: aligned toggle input next to labels
Nov 8, 2024
61fa41f
fixed check for mobile
geckod22 Nov 11, 2024
8374c5f
added fix for minified js
geckod22 Nov 11, 2024
1764da6
Tweak: replace "console.log" with "console.error"
Nov 13, 2024
94f7456
Tweak: groups imports by type
AleTorrisi Nov 18, 2024
d4c4074
Tweak: component and variable name in "Advanced Settings" section
AleTorrisi Nov 18, 2024
49feb01
Update includes/RestApi/LinkPrefetchController.php
geckod22 Nov 18, 2024
24dff12
Update includes/RestApi/LinkPrefetchController.php
geckod22 Nov 18, 2024
ecbdb47
updated LinkPrefetchController with more fix
geckod22 Nov 18, 2024
f743bfe
adding suggested improvements to LinkPrefetchController.php
geckod22 Nov 18, 2024
b7f0abd
removed unused Permissions class and removed LinkPrefetch new and con…
geckod22 Nov 18, 2024
1427769
defaultText.js fix
geckod22 Nov 18, 2024
62999b1
Update assets/js/linkPrefetch.js
geckod22 Nov 18, 2024
b5a5284
Update components/linkPrefetch/index.js
geckod22 Nov 18, 2024
c9c5775
moved non-react scripts to scripts folder
geckod22 Nov 18, 2024
2202638
added RestApi.php
geckod22 Nov 18, 2024
5b5c22d
applied suggestion changes to component index.js
geckod22 Nov 18, 2024
319e8c9
Tweak: better handling of Rest API
AleTorrisi Nov 18, 2024
5f18dca
other fixies for RestApi and LinkPrefetch Starting
geckod22 Nov 18, 2024
23ed28b
Tweak: handling of failure during saving options
AleTorrisi Nov 18, 2024
6bf3faf
Tweak: remove unused constant
AleTorrisi Nov 18, 2024
a569d2a
Tweak: parameter name
AleTorrisi Nov 18, 2024
3e39933
Tweak: import 'useState' and ''useEffect' from WordPress library inst…
AleTorrisi Nov 18, 2024
af2d843
moved inline styles to file and load it
geckod22 Nov 18, 2024
d29a258
some phpcs fixiews
geckod22 Nov 18, 2024
e010497
phpcs
geckod22 Nov 18, 2024
be0bf02
Tweak: fetch options function
AleTorrisi Nov 18, 2024
d1c6e62
Fix remove unused text
AleTorrisi Nov 18, 2024
b71cd5f
Tweak: store Jetpack Boost options in NewFold Runtime object avoiding…
AleTorrisi Nov 18, 2024
b58793d
Tweak: handling of style script
AleTorrisi Nov 18, 2024
e2170d6
linkPrefetch.js lint
geckod22 Nov 18, 2024
717557b
Tweak: replaced "src/css" folder with "styles" folder
AleTorrisi Nov 18, 2024
70b1e1f
JS Lint
AleTorrisi Nov 18, 2024
37799c1
Fix phpcs
AleTorrisi Nov 18, 2024
a113d03
phpcs fix
AleTorrisi Nov 18, 2024
ba9e987
show the caching admin bar item and dynamically set the settings link…
geckod22 Nov 19, 2024
96f9b80
Lint js files
arunshenoy99 Nov 20, 2024
736cf48
New: upsell option "Optimize Critical CSS Loading"
AleTorrisi Nov 25, 2024
3bbc47a
Removed useless comment
AleTorrisi Nov 25, 2024
2f0e7d7
Fix: hide premium option "Critical CSS" when module is disabled
AleTorrisi Nov 26, 2024
0e5d09a
Test commit for cy test
AleTorrisi Nov 26, 2024
c748863
Fix: Jetpack Boost upsell link
AleTorrisi Nov 26, 2024
a78673c
fix for mousedown event
geckod22 Nov 27, 2024
74361d5
Fix: get correctly the site url in case of subdomain
AleTorrisi Nov 27, 2024
cd5d1d8
adding minified js
geckod22 Nov 27, 2024
e7e7c10
Testing cypress fix
arunshenoy99 Dec 12, 2024
64bf1bd
Fix Web and Mojo fatal error
arunshenoy99 Dec 12, 2024
150f392
Merge pull request #25 from newfold-labs/enhance/PRESS7-60-jetpack-boost
arunshenoy99 Dec 14, 2024
9fc34ae
Merge branch 'release/v2.1.0' of https://github.com/newfold-labs/wp-m…
arunshenoy99 Dec 14, 2024
e8537e7
Merge pull request #26 from newfold-labs/enhance/PRESS7-64-link-prefetch
arunshenoy99 Dec 14, 2024
d2577fe
Merge branch 'release/v2.1.0' of https://github.com/newfold-labs/wp-m…
arunshenoy99 Dec 14, 2024
e082ccc
Merge pull request #29 from newfold-labs/fix/PRESS7-78-clear-cache-ba…
arunshenoy99 Dec 14, 2024
f94146f
Fix: set default value for exclusion settings
AleTorrisi Dec 16, 2024
dc9112c
fixed issue when exclude keywords is empty
geckod22 Dec 16, 2024
6d00bd3
added timeout for ignorekeywords field
geckod22 Dec 16, 2024
4e7e7ef
sanitize ignorekeywords input field
geckod22 Dec 16, 2024
1ef2bfa
little change in jetpack option for a string translation
geckod22 Dec 16, 2024
ea3bf5c
Update lint workflow with path and debug
arunshenoy99 Dec 17, 2024
fae8475
Minor formatting fixes
arunshenoy99 Dec 17, 2024
ebe6485
Fix formatting in PHP files
arunshenoy99 Dec 17, 2024
9e0ab82
Remove debug statement from workflow
arunshenoy99 Dec 17, 2024
2407609
Merge pull request #38 from newfold-labs/release/v2.1.0-bugfix
arunshenoy99 Dec 17, 2024
d9e62a5
Improve lint workflow
arunshenoy99 Dec 17, 2024
5083aeb
Update workflow to wait for 1 second
arunshenoy99 Dec 17, 2024
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
12 changes: 6 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: Lint
name: 'Lint Checker: PHP'

on:
push:
branches:
- '**'
paths:
- '**.php'
pull_request:
Expand All @@ -24,17 +23,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# User PHP 7.4 here for compatibility with the WordPress codesniffer rules.
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.2'
coverage: none
tools: composer, cs2pr

- uses: technote-space/get-diff-action@v6
with:
SUFFIX_FILTER: .php
PATTERNS: |
**/*.php
!build/**/*.php

- name: Get Composer cache directory
id: composer-cache
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// WordPress
import { useState } from '@wordpress/element';

// Newfold
import { Spinner } from '@newfold/ui-component-library';
import { NewfoldRuntime } from '@newfold-labs/wp-module-runtime';

const InstallActivatePluginButton = ( {
methods,
constants,
setModuleStatus,
} ) => {
const [ isLoading, setIsLoading ] = useState( false );
const [ isActive, setIsActive ] = useState( false );
const [ message, setMessage ] = useState( null );

const handleInstallActivate = async () => {
setIsLoading( true );
setMessage( constants.text.jetpackBoostInstalling );

const apiUrl = methods.NewfoldRuntime.createApiUrl(
'/newfold-installer/v1/plugins/install'
);
const INSTALL_TOKEN = NewfoldRuntime.sdk.performance.install_token;
const plugin = 'jetpack-boost';

try {
await methods.apiFetch( {
url: apiUrl,
method: 'POST',
headers: { 'X-NFD-INSTALLER': INSTALL_TOKEN },
data: { plugin, activate: true, queue: false },
} );
setIsActive( true );
setModuleStatus( true );
setMessage( constants.text.jetpackBoostInstalling );
} catch ( error ) {
setMessage( constants.text.jetpackBoostActivationFailed );
} finally {
setIsLoading( false );
}
};

return (
<div className="nfd-performance-jetpack-boost-container-install-activate-button">
<button
className="nfd-button--upsell"
onClick={ handleInstallActivate }
>
{ isLoading ? (
<>
<Spinner />
<p>{ message }</p>
</>
) : (
! isActive && (
<>
<span>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth="2"
stroke="currentColor"
aria-hidden="true"
className="nfd-w-5 nfd-h-5 nfd--ml-1 nfd-shrink-0"
role="img"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"
></path>
</svg>
</span>
<span>{ constants.text.jetpackBoostCtaText }</span>
</>
)
) }
</button>
</div>
);
};

export default InstallActivatePluginButton;
184 changes: 184 additions & 0 deletions components/advancedSettings/JetpackBoost/SingleOption.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// WordPress
import apiFetch from '@wordpress/api-fetch';
import { useRef, useState } from '@wordpress/element';

// Newfold
import {
ToggleField,
Textarea,
FeatureUpsell,
} from '@newfold/ui-component-library';
import { NewfoldRuntime } from '@newfold-labs/wp-module-runtime';

// Third-parts
import parse from 'html-react-parser';

const SingleOption = ( { params, isChild, methods, constants } ) => {
const [ optionDetails, setOptionDetails ] = useState( {
id: params.id,
label: params.label,
description: params.description,
value: params.value ? String( params.value ) : '',
type: params.type,
externalText: params.externalText,
premiumUrl: params.premiumUrl ?? '',
children: params.children,
} );

const [ isShown, setIsShown ] = useState( false );

const debounceTimeout = useRef( null ); // Mantiene il timeout tra i render

const handleChangeOption = ( value, id ) => {
if ( typeof value === 'object' ) {
value = value.target.value;
}

setOptionDetails( { ...optionDetails, value } );

// Clear the previous timeout if user types again.
if ( debounceTimeout.current ) {
clearTimeout( debounceTimeout.current );
}

// Set a new timeout of 2 seconds.
debounceTimeout.current = setTimeout( () => {
apiFetch( {
path: 'newfold-performance/v1/jetpack/settings',
method: 'POST',
data: {
field: {
id,
value,
},
},
} )
.then( () => {
methods.makeNotice(
'cache-level-change-notice',
constants.text.optionSet,
'',
'success',
5000
);
} )
.catch( () => {
methods.makeNotice(
'cache-level-change-notice',
constants.text.optionNotSet,
'',
'error',
5000
);
} );
}, 1000 );
};

const displayOption = ( option ) => {
switch ( option.type ) {
case 'toggle':
return (
<>
{ option.premiumUrl &&
! NewfoldRuntime.sdk.performance
.jetpack_boost_premium_is_active && (
<FeatureUpsell
cardText="Upgrade to Unlock"
cardLink={ option.premiumUrl }
>
<ToggleField
id={ option.id }
label={ option.label }
description={ parse(
option.description
) }
checked={ !! option.value }
onChange={ ( value ) =>
handleChangeOption(
value,
option.id
)
}
/>
{ option.externalText ? (
<p
style={ {
textDecoration: 'underline',
margin: '10px 0',
} }
>
{ parse( option.externalText ) }
</p>
) : null }
</FeatureUpsell>
) }
{ ( ! option.premiumUrl ||
NewfoldRuntime.sdk.performance
.jetpack_boost_premium_is_active ) && (
<>
<ToggleField
id={ option.id }
label={ option.label }
description={ option.description }
checked={ !! option.value }
onChange={ ( value ) =>
handleChangeOption( value, option.id )
}
/>
{ option.externalText ? (
<p
style={ {
textDecoration: 'underline',
margin: '10px 0',
} }
>
{ parse( option.externalText ) }
</p>
) : null }
</>
) }
</>
);

case 'textarea':
return (
<>
<p className="field-label">{ option.label }</p>
<Textarea
id={ option.id }
description={ option.description }
value={ option.value ?? '' }
onChange={ ( value ) => {
handleChangeOption( value, option.id );
} }
/>
</>
);
default:
return null;
}
};

return (
<>
{ isChild && (
<div className="child-field">
<div
className="wrap-button"
style={ { textAlign: 'right' } }
>
<button onClick={ () => setIsShown( ! isShown ) }>
{ isShown
? constants.text.jetpackBoostShowLess
: constants.text.jetpackBoostShowMore }
</button>
</div>
{ isShown && displayOption( optionDetails ) }
</div>
) }
{ ! isChild && displayOption( optionDetails ) }
</>
);
};

export default SingleOption;
Loading
Loading