diff --git a/components/advancedSettings/JetpackBoost/SingleOption.js b/components/advancedSettings/JetpackBoost/SingleOption.js index 9da7949..1aa09e8 100644 --- a/components/advancedSettings/JetpackBoost/SingleOption.js +++ b/components/advancedSettings/JetpackBoost/SingleOption.js @@ -83,7 +83,7 @@ const SingleOption = ( { params, isChild, methods, constants } ) => { ! NewfoldRuntime.sdk.performance .jetpack_boost_premium_is_active && ( { - const [ cacheLevel, setCacheLevel ] = methods.useState(constants.store.cacheLevel); +const CacheSettings = ( { methods, constants, Components } ) => { + const [ cacheLevel, setCacheLevel ] = methods.useState( + constants.store.cacheLevel + ); - const cacheOptions = [ - { - label: constants.text.cacheLevel0Label, - description: constants.text.cacheLevel0Description + constants.text.cacheLevel0Recommendation, - value: 0, - notice: constants.text.cacheLevel0NoticeText, - }, - { - label: constants.text.cacheLevel1Label, - description: constants.text.cacheLevel1Description + constants.text.cacheLevel1Recommendation, - value: 1, - notice: constants.text.cacheLevel1NoticeText, - }, - { - label: constants.text.cacheLevel2Label, - description: constants.text.cacheLevel2Description + constants.text.cacheLevel2Recommendation, - value: 2, - notice: constants.text.cacheLevel2NoticeText, - }, - { - label: constants.text.cacheLevel3Label, - description: constants.text.cacheLevel3Description + constants.text.cacheLevel3Recommendation, - value: 3, - notice: constants.text.cacheLevel3NoticeText, - }, - ]; + const cacheOptions = [ + { + label: constants.text.cacheLevel0Label, + description: + constants.text.cacheLevel0Description + + constants.text.cacheLevel0Recommendation, + value: 0, + notice: constants.text.cacheLevel0NoticeText, + }, + { + label: constants.text.cacheLevel1Label, + description: + constants.text.cacheLevel1Description + + constants.text.cacheLevel1Recommendation, + value: 1, + notice: constants.text.cacheLevel1NoticeText, + }, + { + label: constants.text.cacheLevel2Label, + description: + constants.text.cacheLevel2Description + + constants.text.cacheLevel2Recommendation, + value: 2, + notice: constants.text.cacheLevel2NoticeText, + }, + { + label: constants.text.cacheLevel3Label, + description: + constants.text.cacheLevel3Description + + constants.text.cacheLevel3Recommendation, + value: 3, + notice: constants.text.cacheLevel3NoticeText, + }, + ]; - const getCacheLevelNoticeTitle = () => { - return constants.text.cacheLevelNoticeTitle; - }; + const getCacheLevelNoticeTitle = () => { + return constants.text.cacheLevelNoticeTitle; + }; - const getCacheLevelNoticeText = () => { - return cacheOptions[cacheLevel].notice; - }; + const getCacheLevelNoticeText = () => { + return cacheOptions[ cacheLevel ].notice; + }; - const handleCacheLevelChange = (e) => { - methods.newfoldSettingsApiFetch( - { cacheLevel: parseInt(e.target.value) }, - methods.setError, (response) => { - setCacheLevel(parseInt(e.target.value)); - } - ); - }; + const handleCacheLevelChange = ( e ) => { + methods.newfoldSettingsApiFetch( + { cacheLevel: parseInt( e.target.value ) }, + methods.setError, + ( response ) => { + setCacheLevel( parseInt( e.target.value ) ); + } + ); + }; - methods.useUpdateEffect(() => { - methods.setStore({ - ...constants.store, - cacheLevel, - }); + methods.useUpdateEffect( () => { + methods.setStore( { + ...constants.store, + cacheLevel, + } ); - methods.makeNotice( - "cache-level-change-notice", - getCacheLevelNoticeTitle(), - getCacheLevelNoticeText(), - "success", - 5000 - ); - }, [cacheLevel]); + methods.makeNotice( + 'cache-level-change-notice', + getCacheLevelNoticeTitle(), + getCacheLevelNoticeText(), + 'success', + 5000 + ); + }, [ cacheLevel ] ); - return ( - <> - - - {cacheOptions.map((option) => { - return ( - - -
- {option.description} -
-
- ); - })} -
-
- - ); -} + return ( + <> + + + { cacheOptions.map( ( option ) => { + return ( + + +
+ { option.description } +
+
+ ); + } ) } +
+
+ + ); +}; -export default CacheSettings; \ No newline at end of file +export default CacheSettings; diff --git a/components/clearCache/index.js b/components/clearCache/index.js index 793ddab..494a3fc 100644 --- a/components/clearCache/index.js +++ b/components/clearCache/index.js @@ -1,39 +1,37 @@ -import { Button, Container } from "@newfold/ui-component-library"; +import { Button, Container } from '@newfold/ui-component-library'; -const ClearCache = ({ methods, constants }) => { +const ClearCache = ( { methods, constants } ) => { + const clearCache = () => { + methods.newfoldPurgeCacheApiFetch( + {}, + methods.setError, + ( response ) => { + methods.makeNotice( + 'disable-old-posts-comments-notice', + constants.text.clearCacheNoticeTitle, + null, + 'success', + 5000 + ); + } + ); + }; - const clearCache = () => { - methods.newfoldPurgeCacheApiFetch( - {}, - methods.setError, - (response) => { - methods.makeNotice( - "disable-old-posts-comments-notice", - constants.text.clearCacheNoticeTitle, - null, - "success", - 5000 - ); - } - ); - }; + return ( + + + + ); +}; - return ( - - - - - ); -;} - -export default ClearCache; \ No newline at end of file +export default ClearCache; diff --git a/includes/burstSafetyModeFunctions.php b/includes/burstSafetyModeFunctions.php index 8de058d..6cc03cc 100644 --- a/includes/burstSafetyModeFunctions.php +++ b/includes/burstSafetyModeFunctions.php @@ -1,4 +1,4 @@ -addHeader( 'X-Newfold-Cache-Level', 3 ); } } elseif ( $newfold_burst_safety_mode ) { $cache_level = get_option( 'newfold_burst_safety_mode_site_cache_level' ); $browser = new Browser(); $browser::maybeAddRules( $cache_level ); - if( function_exists( 'getSkip404Option' ) && ! getSkip404Option() ) { - $skip404 = new Skip404(); - $skip404::maybeAddRules( false ); - } - $responseHeaderManager = new ResponseHeaderManager(); - $responseHeaderManager->addHeader( 'X-Newfold-Cache-Level', $cache_level ); + if ( function_exists( 'getSkip404Option' ) && ! getSkip404Option() ) { + $skip404 = new Skip404(); + $skip404::maybeAddRules( false ); + } + $responseHeaderManager = new ResponseHeaderManager(); + $responseHeaderManager->addHeader( 'X-Newfold-Cache-Level', $cache_level ); delete_option( 'newfold_burst_safety_mode' ); delete_option( 'newfold_burst_safety_mode_site_cache_level' ); }