| 1 |
<?php |
| 2 |
namespace Elementor; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; // Exit if accessed directly. |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Elementor text stroke control. |
| 10 |
* |
| 11 |
* A group control for creating a stroke effect on text. Displays input fields to define |
| 12 |
* the text stroke and color stroke. |
| 13 |
* |
| 14 |
* @since 3.5.0 |
| 15 |
*/ |
| 16 |
class Group_Control_Text_Stroke extends Group_Control_Base { |
| 17 |
|
| 18 |
/** |
| 19 |
* Fields. |
| 20 |
* |
| 21 |
* Holds all the text stroke control fields. |
| 22 |
* |
| 23 |
* @since 3.5.0 |
| 24 |
* @access protected |
| 25 |
* @static |
| 26 |
* |
| 27 |
* @var array Text Stroke control fields. |
| 28 |
*/ |
| 29 |
protected static $fields; |
| 30 |
|
| 31 |
/** |
| 32 |
* Get text stroke control type. |
| 33 |
* |
| 34 |
* Retrieve the control type, in this case `text-stroke`. |
| 35 |
* |
| 36 |
* @since 3.5.0 |
| 37 |
* @access public |
| 38 |
* @static |
| 39 |
* |
| 40 |
* @return string Control type. |
| 41 |
*/ |
| 42 |
public static function get_type() { |
| 43 |
return 'text-stroke'; |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Init fields. |
| 48 |
* |
| 49 |
* Initialize text stroke control fields. |
| 50 |
* |
| 51 |
* @since 3.5.0 |
| 52 |
* @access protected |
| 53 |
* |
| 54 |
* @return array Control fields. |
| 55 |
*/ |
| 56 |
protected function init_fields() { |
| 57 |
$controls = []; |
| 58 |
|
| 59 |
$controls['text_stroke'] = [ |
| 60 |
'label' => esc_html__( 'Text Stroke', 'elementor' ), |
| 61 |
'type' => Controls_Manager::SLIDER, |
| 62 |
'size_units' => [ 'px', 'em', 'rem', 'custom' ], |
| 63 |
'range' => [ |
| 64 |
'px' => [ |
| 65 |
'min' => 0, |
| 66 |
'max' => 10, |
| 67 |
], |
| 68 |
'em' => [ |
| 69 |
'min' => 0, |
| 70 |
'max' => 1, |
| 71 |
], |
| 72 |
'rem' => [ |
| 73 |
'min' => 0, |
| 74 |
'max' => 1, |
| 75 |
], |
| 76 |
], |
| 77 |
'responsive' => true, |
| 78 |
'selector' => '{{WRAPPER}}', |
| 79 |
'selectors' => [ |
| 80 |
'{{SELECTOR}}' => '-webkit-text-stroke-width: {{SIZE}}{{UNIT}}; stroke-width: {{SIZE}}{{UNIT}};', |
| 81 |
], |
| 82 |
]; |
| 83 |
|
| 84 |
$controls['stroke_color'] = [ |
| 85 |
'label' => esc_html__( 'Stroke Color', 'elementor' ), |
| 86 |
'type' => Controls_Manager::COLOR, |
| 87 |
'default' => '#000', |
| 88 |
'selector' => '{{WRAPPER}}', |
| 89 |
'selectors' => [ |
| 90 |
'{{SELECTOR}}' => '-webkit-text-stroke-color: {{VALUE}}; stroke: {{VALUE}};', |
| 91 |
], |
| 92 |
]; |
| 93 |
|
| 94 |
return $controls; |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Get default options. |
| 99 |
* |
| 100 |
* Retrieve the default options of the text stroke control. Used to return the |
| 101 |
* default options while initializing the text stroke control. |
| 102 |
* |
| 103 |
* @since 3.5.0 |
| 104 |
* @access protected |
| 105 |
* |
| 106 |
* @return array Default text stroke control options. |
| 107 |
*/ |
| 108 |
protected function get_default_options() { |
| 109 |
return [ |
| 110 |
'popover' => [ |
| 111 |
'starter_title' => esc_html__( 'Text Stroke', 'elementor' ), |
| 112 |
'starter_name' => 'text_stroke_type', |
| 113 |
'starter_value' => 'yes', |
| 114 |
'settings' => [ |
| 115 |
'render_type' => 'ui', |
| 116 |
], |
| 117 |
], |
| 118 |
]; |
| 119 |
} |
| 120 |
} |
| 121 |
|