| @@ -1,0 +1,57 @@ | ||
| 1 | +<?php | |
| 2 | +namespace ABlocks\Controls; | |
| 3 | + | |
| 4 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 5 | + exit; | |
| 6 | +} | |
| 7 | + | |
| 8 | +use ABlocks\Classes\ControlBaseAbstract; | |
| 9 | +use ABlocks\Controls\Color; | |
| 10 | + | |
| 11 | +class TextStroke extends ControlBaseAbstract { | |
| 12 | + public static function get_attribute_default_value( $is_responsive = false ) { | |
| 13 | + if ( $is_responsive ) { | |
| 14 | + return array( | |
| 15 | + 'strokeWidth' => '', | |
| 16 | + 'strokeWidthTablet' => '', | |
| 17 | + 'strokeWidthMobile' => '', | |
| 18 | + 'strokeWidthUnit' => 'px', | |
| 19 | + 'strokeWidthUnitTablet' => 'px', | |
| 20 | + 'strokeWidthUnitMobile' => 'px', | |
| 21 | + 'stroke' => '', | |
| 22 | + ); | |
| 23 | + } | |
| 24 | + return array( | |
| 25 | + 'strokeWidth' => '', | |
| 26 | + 'strokeWidthUnit' => 'px', | |
| 27 | + 'stroke' => '', | |
| 28 | + ); | |
| 29 | + } | |
| 30 | + | |
| 31 | + public static function get_attribute( $attributeName, $isResponsive = false ) { | |
| 32 | + return [ | |
| 33 | + $attributeName => [ | |
| 34 | + 'type' => 'object', | |
| 35 | + 'default' => self::get_attribute_default_value( $isResponsive ), | |
| 36 | + ] | |
| 37 | + ]; | |
| 38 | + } | |
| 39 | + | |
| 40 | + public static function get_css( $attribute_value, $property = '', $device = '' ) { | |
| 41 | + if ( empty( $attribute_value ) ) { | |
| 42 | + return []; | |
| 43 | + } | |
| 44 | + $default_attar_value = self::get_attribute_default_value( (bool) $device ); | |
| 45 | + $value = wp_parse_args( $attribute_value, $default_attar_value ); | |
| 46 | + $css = []; | |
| 47 | + | |
| 48 | + if ( '' !== $value[ 'strokeWidth' . $device ] ) { | |
| 49 | + $css['-webkit-text-stroke-width'] = $value[ 'strokeWidth' . $device ] . $value[ 'strokeWidthUnit' . $device ]; | |
| 50 | + $css['-webkit-text-stroke-color'] = Color::get_css( '' !== $value['stroke'] ? $value['stroke'] : '#000' ); | |
| 51 | + } | |
| 52 | + | |
| 53 | + return $css; | |
| 54 | + } | |
| 55 | + | |
| 56 | + | |
| 57 | +} | |