| @@ -20,11 +20,14 @@ | ||
| 20 | 20 | * background → Accent (`theme-color`), hover background → Link Hover |
| 21 | 21 | * (`link-h-color`), and each text partner → the colour that reads on its |
| 22 | 22 | * background. |
| 23 | 23 | * |
| 24 | + * Its Buttons → Border Radius (`button-radius-fields`) is the button radius | |
| 25 | + * (see radii()). Astra has no form-field or product-card radius setting. | |
| 26 | + * | |
| 24 | 27 | * Verified against Astra 4.13.11. |
| 25 | 28 | */ |
| 26 | -class AstraSettingsReader implements ThemeSettingsReader | |
| 29 | +class AstraSettingsReader implements ThemeSettingsReader, ThemeRadiusReader | |
| 27 | 30 | { |
| 28 | 31 | /** |
| 29 | 32 | * Astra's outline button presets: a transparent background with a border. |
| 30 | 33 | * |
| @@ -155,6 +158,48 @@ | ||
| 155 | 158 | return ''; |
| 156 | 159 | } |
| 157 | 160 | |
| 158 | 161 | return ThemePalette::settingValue(Arr::get($value, 'desktop.background-color', '')); |
| 162 | + } | |
| 163 | + | |
| 164 | + /** | |
| 165 | + * The primary button's Border Radius. | |
| 166 | + * | |
| 167 | + * `button-radius-fields` is a responsive four-corner control; Astra prints | |
| 168 | + * each desktop corner as `<value><desktop-unit>` (astra_responsive_spacing() | |
| 169 | + * in inc/class-astra-dynamic-css.php) and tablet/mobile only override it, | |
| 170 | + * so desktop speaks for all. Only four equal corners are one length. An | |
| 171 | + * empty corner prints nothing — Astra's stylesheet then paints `button` | |
| 172 | + * 2px but `.button` 0, no single answer — so an empty radius states none. | |
| 173 | + * | |
| 174 | + * @return array Role => length, as Astra prints it. | |
| 175 | + */ | |
| 176 | + public static function radii(): array | |
| 177 | + { | |
| 178 | + if (!self::applies()) { | |
| 179 | + return []; | |
| 180 | + } | |
| 181 | + | |
| 182 | + $fields = astra_get_option('button-radius-fields'); | |
| 183 | + | |
| 184 | + if (!is_array($fields) || !isset($fields['desktop']) || !is_array($fields['desktop'])) { | |
| 185 | + return []; | |
| 186 | + } | |
| 187 | + | |
| 188 | + $unit = isset($fields['desktop-unit']) && is_string($fields['desktop-unit']) && $fields['desktop-unit'] !== '' | |
| 189 | + ? $fields['desktop-unit'] | |
| 190 | + : 'px'; | |
| 191 | + $corners = []; | |
| 192 | + | |
| 193 | + foreach (['top', 'right', 'bottom', 'left'] as $side) { | |
| 194 | + $value = isset($fields['desktop'][$side]) ? $fields['desktop'][$side] : ''; | |
| 195 | + | |
| 196 | + if (!is_numeric($value)) { | |
| 197 | + return []; | |
| 198 | + } | |
| 199 | + | |
| 200 | + $corners[] = $value . $unit; | |
| 201 | + } | |
| 202 | + | |
| 203 | + return count(array_unique($corners)) === 1 ? ['btn' => $corners[0]] : []; | |
| 159 | 204 | } |
| 160 | 205 | } |