| 1 |
<?php |
| 2 |
namespace Elementor; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Elementor border control. |
| 10 |
* |
| 11 |
* A base control for creating border control. Displays input fields to define |
| 12 |
* border type, border width and border color. |
| 13 |
* |
| 14 |
* @since 1.0.0 |
| 15 |
*/ |
| 16 |
class Group_Control_Border extends Group_Control_Base { |
| 17 |
|
| 18 |
/** |
| 19 |
* Fields. |
| 20 |
* |
| 21 |
* Holds all the border control fields. |
| 22 |
* |
| 23 |
* @since 1.0.0 |
| 24 |
* @access protected |
| 25 |
* @static |
| 26 |
* |
| 27 |
* @var array Border control fields. |
| 28 |
*/ |
| 29 |
protected static $fields; |
| 30 |
|
| 31 |
/** |
| 32 |
* Get border control type. |
| 33 |
* |
| 34 |
* Retrieve the control type, in this case `border`. |
| 35 |
* |
| 36 |
* @since 1.0.0 |
| 37 |
* @access public |
| 38 |
* @static |
| 39 |
* |
| 40 |
* @return string Control type. |
| 41 |
*/ |
| 42 |
public static function get_type() { |
| 43 |
return 'border'; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Init fields. |
| 48 |
* |
| 49 |
* Initialize border control fields. |
| 50 |
* |
| 51 |
* @since 1.2.2 |
| 52 |
* @access protected |
| 53 |
* |
| 54 |
* @return array Control fields. |
| 55 |
*/ |
| 56 |
protected function init_fields() { |
| 57 |
$fields = []; |
| 58 |
|
| 59 |
$fields['border'] = [ |
| 60 |
'label' => esc_html__( 'Border Type', 'elementor' ), |
| 61 |
'type' => Controls_Manager::SELECT, |
| 62 |
'options' => [ |
| 63 |
'' => esc_html__( 'Default', 'elementor' ), |
| 64 |
'none' => esc_html__( 'None', 'elementor' ), |
| 65 |
'solid' => esc_html__( 'Solid', 'elementor' ), |
| 66 |
'double' => esc_html__( 'Double', 'elementor' ), |
| 67 |
'dotted' => esc_html__( 'Dotted', 'elementor' ), |
| 68 |
'dashed' => esc_html__( 'Dashed', 'elementor' ), |
| 69 |
'groove' => esc_html__( 'Groove', 'elementor' ), |
| 70 |
], |
| 71 |
'selectors' => [ |
| 72 |
'{{SELECTOR}}' => 'border-style: {{VALUE}};', |
| 73 |
], |
| 74 |
]; |
| 75 |
|
| 76 |
$fields['width'] = [ |
| 77 |
'label' => esc_html__( 'Border Width', 'elementor' ), |
| 78 |
'type' => Controls_Manager::DIMENSIONS, |
| 79 |
'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ], |
| 80 |
'selectors' => [ |
| 81 |
'{{SELECTOR}}' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 82 |
], |
| 83 |
'condition' => [ |
| 84 |
'border!' => [ '', 'none' ], |
| 85 |
], |
| 86 |
'responsive' => true, |
| 87 |
]; |
| 88 |
|
| 89 |
$fields['color'] = [ |
| 90 |
'label' => esc_html__( 'Border Color', 'elementor' ), |
| 91 |
'type' => Controls_Manager::COLOR, |
| 92 |
'default' => '', |
| 93 |
'selectors' => [ |
| 94 |
'{{SELECTOR}}' => 'border-color: {{VALUE}};', |
| 95 |
], |
| 96 |
'condition' => [ |
| 97 |
'border!' => [ '', 'none' ], |
| 98 |
], |
| 99 |
]; |
| 100 |
|
| 101 |
return $fields; |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Get default options. |
| 106 |
* |
| 107 |
* Retrieve the default options of the border control. Used to return the |
| 108 |
* default options while initializing the border control. |
| 109 |
* |
| 110 |
* @since 1.9.0 |
| 111 |
* @access protected |
| 112 |
* |
| 113 |
* @return array Default border control options. |
| 114 |
*/ |
| 115 |
protected function get_default_options() { |
| 116 |
return [ |
| 117 |
'popover' => false, |
| 118 |
]; |
| 119 |
} |
| 120 |
} |
| 121 |
|