← All changes
|
app/Services/Theme/Readers/KadenceSettingsReader.php
+41
-1
1.7.0
→
1.7.1
View file →
| @@ -25,11 +25,16 @@ | ||
| 25 | 25 | * |
| 26 | 26 | * Kadence has no border setting (its borders use the static |
| 27 | 27 | * `--global-gray-400`), so no border is stated and FluentCart keeps deriving it. |
| 28 | 28 | * |
| 29 | + * Its Buttons → Border Radius (`buttons_border_radius`) is the button radius | |
| 30 | + * (see radii()). Kadence has no form-field radius setting (its stylesheet's | |
| 31 | + * inputs are a fixed 3px) and its product-archive radii are WooCommerce | |
| 32 | + * settings, so neither is read. | |
| 33 | + * | |
| 29 | 34 | * Verified against Kadence 1.5.0. |
| 30 | 35 | */ |
| 31 | -class KadenceSettingsReader implements ThemeSettingsReader | |
| 36 | +class KadenceSettingsReader implements ThemeSettingsReader, ThemeRadiusReader | |
| 32 | 37 | { |
| 33 | 38 | /** |
| 34 | 39 | * Kadence's defaults per setting and sub-key |
| 35 | 40 | * (inc/components/options/component.php, defaults()). |
| @@ -259,6 +264,41 @@ | ||
| 259 | 264 | return null; |
| 260 | 265 | } |
| 261 | 266 | |
| 262 | 267 | return is_object($kadence) ? $kadence : null; |
| 268 | + } | |
| 269 | + | |
| 270 | + /** | |
| 271 | + * The button radius. | |
| 272 | + * | |
| 273 | + * `buttons_border_radius` is a responsive range (`size` / `unit` per | |
| 274 | + * device) Kadence prints through `render_range()` on its button selector | |
| 275 | + * (inc/components/styles/component.php); the desktop rule is the | |
| 276 | + * unprefixed one that speaks for all. A desktop size that is not a number | |
| 277 | + * prints nothing, and Kadence's stylesheet paints its buttons 3px | |
| 278 | + * (assets/css/global.min.css), which is what is stated then. | |
| 279 | + * | |
| 280 | + * @return array Role => length, as Kadence prints it. | |
| 281 | + */ | |
| 282 | + public static function radii(): array | |
| 283 | + { | |
| 284 | + if (!self::applies()) { | |
| 285 | + return []; | |
| 286 | + } | |
| 287 | + | |
| 288 | + try { | |
| 289 | + $range = self::api()->option('buttons_border_radius'); | |
| 290 | + } catch (\Throwable $e) { | |
| 291 | + return []; | |
| 292 | + } | |
| 293 | + | |
| 294 | + $size = is_array($range) ? Arr::get($range, 'size.desktop', '') : ''; | |
| 295 | + | |
| 296 | + if (!is_numeric($size)) { | |
| 297 | + return ['btn' => '3px']; | |
| 298 | + } | |
| 299 | + | |
| 300 | + $unit = is_array($range) ? (string)Arr::get($range, 'unit.desktop', '') : ''; | |
| 301 | + | |
| 302 | + return ['btn' => $size . ($unit !== '' ? $unit : 'px')]; | |
| 263 | 303 | } |
| 264 | 304 | } |