Skip to content

Commit 7d0a7f1

Browse files
Remove badge setting option
1 parent ffbaa6e commit 7d0a7f1

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

assets/src/dashboard/parts/connected/settings/General.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ import { useSelect } from '@wordpress/data';
1616

1717
import { Icon, chevronDown, chevronUp } from '@wordpress/icons';
1818

19+
import {
20+
useState
21+
} from '@wordpress/element';
22+
1923
/**
2024
* Internal dependencies.
2125
*/
@@ -40,10 +44,11 @@ const General = ({
4044
const isReportEnabled = 'disabled' !== settings[ 'report_script' ];
4145
const isAssetsEnabled = 'disabled' !== settings.cdn;
4246
const isBannerEnabled = 'disabled' !== settings[ 'banner_frontend'];
43-
const isOpenBadgeSetting = 'disabled' !== settings[ 'badge_setting' ];
4447
const isShowBadgeIcon = 'disabled' !== settings[ 'show_badge_icon' ];
4548
const activeBadgePosition = settings[ 'badge_position' ] || 'right';
4649

50+
const [ showBadgeSettings, setBadgeSettings ] = useState( isBannerEnabled );
51+
4752
const updateOption = ( option, value ) => {
4853
setCanSave( true );
4954
const data = { ...settings };
@@ -112,7 +117,10 @@ const General = ({
112117
'is-disabled': isLoading
113118
}
114119
) }
115-
onChange={ value => updateOption( 'banner_frontend', value ) }
120+
onChange={ (value) => {
121+
updateOption( 'banner_frontend', value );
122+
setBadgeSettings( value );
123+
} }
116124
/>
117125

118126
{ isBannerEnabled && (
@@ -124,16 +132,16 @@ const General = ({
124132
'is-disabled': isLoading
125133
}
126134
) }
127-
onClick={ () => updateOption( 'badge_setting', ! isOpenBadgeSetting ) }
135+
onClick={ () => setBadgeSettings( ! showBadgeSettings ) }
128136
>
129137
<span>{ optimoleDashboardApp.strings.options_strings.enable_badge_settings }</span>
130138
<Icon
131-
icon={ ! isOpenBadgeSetting ? chevronUp : chevronDown }
139+
icon={ showBadgeSettings ? chevronUp : chevronDown }
132140
className="h-5 w-5"
133141
style={{ fill: '#3b82f6' }}
134142
/>
135143
</Button>
136-
{ ! isOpenBadgeSetting && (
144+
{ showBadgeSettings && (
137145
<div class="mt-4 space-y-4 pl-4 pt-2">
138146
<div class="flex items-center justify-between mb-4">
139147
<label class="text-gray-600 font-medium">{ optimoleDashboardApp.strings.options_strings.enable_badge_show_icon }</label>

inc/manager.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,8 @@ public function banner() {
177177
return;
178178
}
179179

180-
$badge_setting = $this->settings->get( 'badge_setting' ) === 'enabled';
181-
182-
$position = 'right';
183-
$show_icon_only = false;
184-
if ( ! $badge_setting ) {
185-
$position = $this->settings->get( 'badge_position' ) ?? 'right';
186-
$show_icon_only = $this->settings->get( 'show_badge_icon' ) === 'enabled';
187-
}
180+
$position = $this->settings->get( 'badge_position' ) ?? 'right';
181+
$show_icon_only = $this->settings->get( 'show_badge_icon' ) === 'enabled';
188182

189183
$string = __( 'Optimized by Optimole', 'optimole-wp' );
190184
$div_style = [

inc/settings.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ class Optml_Settings {
101101
'offload_limit' => 50000,
102102
'placeholder_color' => '',
103103
'show_offload_finish_notice' => '',
104-
'badge_setting' => 'disabled',
105104
'show_badge_icon' => 'disabled',
106105
'badge_position' => 'left',
107106
];
@@ -270,7 +269,6 @@ public function parse_settings( $new_settings ) {
270269
case 'best_format':
271270
case 'offload_limit_reached':
272271
case 'show_badge_icon':
273-
case 'badge_setting':
274272
$sanitized_value = $this->to_map_values( $value, [ 'enabled', 'disabled' ], 'enabled' );
275273
break;
276274
case 'offload_limit':
@@ -538,7 +536,6 @@ public function get_site_settings() {
538536
'offload_limit_reached' => $this->get( 'offload_limit_reached' ),
539537
'placeholder_color' => $this->get( 'placeholder_color' ),
540538
'show_offload_finish_notice' => $this->get( 'show_offload_finish_notice' ),
541-
'badge_setting' => $this->get( 'badge_setting' ),
542539
'show_badge_icon' => $this->get( 'show_badge_icon' ),
543540
'badge_position' => $this->get( 'badge_position' ),
544541
];

0 commit comments

Comments
 (0)