| @@ -177,9 +177,9 @@ | ||
| 177 | 177 | ] |
| 178 | 178 | ]; |
| 179 | 179 | } |
| 180 | 180 | public static function get_css( $attribute_value, $property = '', $device = '' ) { |
| 181 | - $value = wp_parse_args( $attribute_value, self::get_attribute_default_value( true ) ); | |
| 181 | + $value = wp_parse_args( $attribute_value, self::responsive_defaults() ); | |
| 182 | 182 | $css = []; |
| 183 | 183 | |
| 184 | 184 | // Separate handling of width units |
| 185 | 185 | if ( $device ) { |
| @@ -191,24 +191,38 @@ | ||
| 191 | 191 | } else { |
| 192 | 192 | $widthUnit = $value['unitWidth']; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - // Handle width | |
| 196 | - if ( $value[ 'isLinkedWidth' . $device ] ) { | |
| 197 | - if ( '' !== $value[ 'commonWidth' . $device ] ) { | |
| 198 | - $css['border-width'] = $value[ 'commonWidth' . $device ] . $widthUnit; | |
| 195 | + // Handle width. Read every device-suffixed member through device_member(): | |
| 196 | + // a custom breakpoint (or the generator's value-less probe suffix) has no | |
| 197 | + // key of its own in the control's defaults, and indexing it directly is | |
| 198 | + // what produced "Undefined array key …" notices on every page. | |
| 199 | + if ( self::device_member( $value, 'isLinkedWidth', $device ) ) { | |
| 200 | + $commonWidth = self::device_member( $value, 'commonWidth', $device ); | |
| 201 | + if ( '' !== $commonWidth ) { | |
| 202 | + $css['border-width'] = $commonWidth . $widthUnit; | |
| 199 | 203 | } |
| 200 | 204 | } else { |
| 201 | - $topWidth = ! empty( $value[ 'topWidth' . $device ] ) ? $value[ 'topWidth' . $device ] : 0; | |
| 202 | - $rightWidth = ! empty( $value[ 'rightWidth' . $device ] ) ? $value[ 'rightWidth' . $device ] : 0; | |
| 203 | - $bottomWidth = ! empty( $value[ 'bottomWidth' . $device ] ) ? $value[ 'bottomWidth' . $device ] : 0; | |
| 204 | - $leftWidth = ! empty( $value[ 'leftWidth' . $device ] ) ? $value[ 'leftWidth' . $device ] : 0; | |
| 205 | + $topWidth = self::device_member( $value, 'topWidth', $device ); | |
| 206 | + $rightWidth = self::device_member( $value, 'rightWidth', $device ); | |
| 207 | + $bottomWidth = self::device_member( $value, 'bottomWidth', $device ); | |
| 208 | + $leftWidth = self::device_member( $value, 'leftWidth', $device ); | |
| 205 | 209 | |
| 206 | - $borderWidth = $topWidth . $widthUnit . ' ' . $rightWidth . $widthUnit . ' ' . $bottomWidth . $widthUnit . ' ' . $leftWidth . $widthUnit; | |
| 210 | + // Only emit border-width when at least one side was actually set — | |
| 211 | + // otherwise every unlinked border produced "border-width:0px 0px 0px 0px". | |
| 212 | + $has_width = '' !== $topWidth || '' !== $rightWidth || '' !== $bottomWidth || '' !== $leftWidth; | |
| 213 | + if ( $has_width ) { | |
| 214 | + $topWidth = ! empty( $topWidth ) ? $topWidth : 0; | |
| 215 | + $rightWidth = ! empty( $rightWidth ) ? $rightWidth : 0; | |
| 216 | + $bottomWidth = ! empty( $bottomWidth ) ? $bottomWidth : 0; | |
| 217 | + $leftWidth = ! empty( $leftWidth ) ? $leftWidth : 0; | |
| 207 | 218 | |
| 208 | - $css['border-width'] = $borderWidth; | |
| 209 | - } | |
| 219 | + $borderWidth = $topWidth . $widthUnit . ' ' . $rightWidth . $widthUnit . ' ' . $bottomWidth . $widthUnit . ' ' . $leftWidth . $widthUnit; | |
| 210 | 220 | |
| 221 | + $css['border-width'] = $borderWidth; | |
| 222 | + } | |
| 223 | + }//end if | |
| 224 | + | |
| 211 | 225 | // Handle border style and color |
| 212 | 226 | if ( '' !== $value['borderStyle'] && 'default' !== $value['borderStyle'] ) { |
| 213 | 227 | $css['border-style'] = $value['borderStyle']; |
| 214 | 228 | } |
| @@ -227,25 +241,26 @@ | ||
| 227 | 241 | $radiusUnit = $value['unitRadius']; |
| 228 | 242 | } |
| 229 | 243 | |
| 230 | 244 | // Handle radius |
| 231 | - if ( $value[ 'isLinkedRadius' . $device ] ) { | |
| 232 | - if ( '' !== $value[ 'commonRadius' . $device ] ) { | |
| 233 | - $css['border-radius'] = $value[ 'commonRadius' . $device ] . $radiusUnit; | |
| 245 | + if ( self::device_member( $value, 'isLinkedRadius', $device ) ) { | |
| 246 | + $commonRadius = self::device_member( $value, 'commonRadius', $device ); | |
| 247 | + if ( '' !== $commonRadius ) { | |
| 248 | + $css['border-radius'] = $commonRadius . $radiusUnit; | |
| 234 | 249 | } |
| 235 | 250 | } else { |
| 236 | - if ( '' !== $value[ 'topRadius' . $device ] ) { | |
| 237 | - $css['border-top-left-radius'] = $value[ 'topRadius' . $device ] . $radiusUnit; | |
| 251 | + $corners = [ | |
| 252 | + 'topRadius' => 'border-top-left-radius', | |
| 253 | + 'rightRadius' => 'border-top-right-radius', | |
| 254 | + 'bottomRadius' => 'border-bottom-right-radius', | |
| 255 | + 'leftRadius' => 'border-bottom-left-radius', | |
| 256 | + ]; | |
| 257 | + foreach ( $corners as $member => $property_name ) { | |
| 258 | + $corner = self::device_member( $value, $member, $device ); | |
| 259 | + if ( '' !== $corner ) { | |
| 260 | + $css[ $property_name ] = $corner . $radiusUnit; | |
| 261 | + } | |
| 238 | 262 | } |
| 239 | - if ( '' !== $value[ 'rightRadius' . $device ] ) { | |
| 240 | - $css['border-top-right-radius'] = $value[ 'rightRadius' . $device ] . $radiusUnit; | |
| 241 | - } | |
| 242 | - if ( '' !== $value[ 'bottomRadius' . $device ] ) { | |
| 243 | - $css['border-bottom-right-radius'] = $value[ 'bottomRadius' . $device ] . $radiusUnit; | |
| 244 | - } | |
| 245 | - if ( '' !== $value[ 'leftRadius' . $device ] ) { | |
| 246 | - $css['border-bottom-left-radius'] = $value[ 'leftRadius' . $device ] . $radiusUnit; | |
| 247 | - } | |
| 248 | 263 | } |
| 249 | 264 | |
| 250 | 265 | // Handle transition duration |
| 251 | 266 | if ( self::has_value( $value['transitionDuration'] ) ) { |
| @@ -268,10 +283,11 @@ | ||
| 268 | 283 | |
| 269 | 284 | if ( ! empty( $value['borderStyleH'] ) && 'default' !== $value['borderStyleH'] ) { |
| 270 | 285 | // Handle hover width |
| 271 | 286 | if ( ! empty( $value[ 'isLinkedWidthH' . $device ] ) ) { |
| 272 | - if ( '' !== $value[ 'commonWidthH' . $device ] ) { | |
| 273 | - $css['border-width'] = $value[ 'commonWidthH' . $device ] . $widthUnit; | |
| 287 | + $commonWidthH = self::device_member( $value, 'commonWidthH', $device ); | |
| 288 | + if ( '' !== $commonWidthH ) { | |
| 289 | + $css['border-width'] = $commonWidthH . $widthUnit; | |
| 274 | 290 | } |
| 275 | 291 | } else { |
| 276 | 292 | $topWidth = ! empty( $value[ 'topWidthH' . $device ] ) ? $value[ 'topWidthH' . $device ] : 0; |
| 277 | 293 | $rightWidth = ! empty( $value[ 'rightWidthH' . $device ] ) ? $value[ 'rightWidthH' . $device ] : 0; |
| @@ -284,9 +300,9 @@ | ||
| 284 | 300 | // Handle hover border color |
| 285 | 301 | if ( ! empty( $value['borderColorH'] ) ) { |
| 286 | 302 | $css['border-color'] = Color::get_css( $value['borderColorH'] ); |
| 287 | 303 | } |
| 288 | - } | |
| 304 | + }//end if | |
| 289 | 305 | |
| 290 | 306 | // Handle hover border style |
| 291 | 307 | if ( ! empty( $value['borderStyleH'] ) && 'default' !== $value['borderStyleH'] ) { |
| 292 | 308 | $css['border-style'] = $value['borderStyleH']; |