| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace JFB_Modules\Jet_Style\Css_Compilers; |
| 5 |
|
| 6 |
use Jet_Form_Builder\Classes\Arrayable\Array_Tools; |
| 7 |
|
| 8 |
// If this file is called directly, abort. |
| 9 |
if ( ! defined( 'WPINC' ) ) { |
| 10 |
die; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* @since 3.1.0 |
| 15 |
* |
| 16 |
* Class Border_Radius_Css_Compiler |
| 17 |
* @package Jet_Form_Builder\Compatibility\Wp_Experiments\Css_Compilers |
| 18 |
*/ |
| 19 |
class Border_Radius_Css_Compiler extends Base_Css_Compiler { |
| 20 |
|
| 21 |
public function is_supported( array $path ): bool { |
| 22 |
return ( |
| 23 |
'border' === ( $path[1] ?? '' ) && |
| 24 |
'radius' === Array_Tools::last( $path ) |
| 25 |
); |
| 26 |
} |
| 27 |
|
| 28 |
public function compile_declarations( |
| 29 |
\WP_Style_Engine_CSS_Declarations $declarations, |
| 30 |
array $root_styles, |
| 31 |
array &$class_names |
| 32 |
) { |
| 33 |
$base_radius = Array_Tools::get( $root_styles, $this->path, array() ); |
| 34 |
|
| 35 |
if ( empty( $base_radius ) ) { |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
$declarations->add_declaration( |
| 40 |
"{$this->css_var}-top-left", |
| 41 |
$this->get_top_left( $base_radius ) |
| 42 |
); |
| 43 |
|
| 44 |
$declarations->add_declaration( |
| 45 |
"{$this->css_var}-top-right", |
| 46 |
$this->get_top_right( $base_radius ) |
| 47 |
); |
| 48 |
|
| 49 |
$declarations->add_declaration( |
| 50 |
"{$this->css_var}-bottom-right", |
| 51 |
$this->get_bottom_right( $base_radius ) |
| 52 |
); |
| 53 |
|
| 54 |
$declarations->add_declaration( |
| 55 |
"{$this->css_var}-bottom-left", |
| 56 |
$this->get_bottom_left( $base_radius ) |
| 57 |
); |
| 58 |
} |
| 59 |
|
| 60 |
public function get_top_left( $value ) { |
| 61 |
return is_array( $value ) ? $value['topLeft'] : $value; |
| 62 |
} |
| 63 |
|
| 64 |
public function get_top_right( $value ) { |
| 65 |
return is_array( $value ) ? $value['topRight'] : $value; |
| 66 |
} |
| 67 |
|
| 68 |
public function get_bottom_left( $value ) { |
| 69 |
return is_array( $value ) ? $value['bottomLeft'] : $value; |
| 70 |
} |
| 71 |
|
| 72 |
public function get_bottom_right( $value ) { |
| 73 |
return is_array( $value ) ? $value['bottomRight'] : $value; |
| 74 |
} |
| 75 |
|
| 76 |
} |
| 77 |
|