| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\ConversionCenter\Traits; |
| 4 |
|
| 5 |
use Elementor\Controls_Manager; |
| 6 |
use Elementor\Shapes; |
| 7 |
use Elementor\Utils; |
| 8 |
|
| 9 |
trait Conversion_Center_Controls_Trait { |
| 10 |
|
| 11 |
protected $border_width_range = [ |
| 12 |
'min' => 0, |
| 13 |
'max' => 10, |
| 14 |
'step' => 1, |
| 15 |
]; |
| 16 |
|
| 17 |
protected function add_html_tag_control( string $name, string $default = 'h2' ): void { |
| 18 |
$this->add_control( |
| 19 |
$name, |
| 20 |
[ |
| 21 |
'label' => esc_html__( 'HTML Tag', 'elementor' ), |
| 22 |
'type' => Controls_Manager::SELECT, |
| 23 |
'options' => [ |
| 24 |
'h1' => 'H1', |
| 25 |
'h2' => 'H2', |
| 26 |
'h3' => 'H3', |
| 27 |
'h4' => 'H4', |
| 28 |
'h5' => 'H5', |
| 29 |
'h6' => 'H6', |
| 30 |
'div' => 'div', |
| 31 |
'span' => 'span', |
| 32 |
'p' => 'p', |
| 33 |
], |
| 34 |
'default' => $default, |
| 35 |
] |
| 36 |
); |
| 37 |
} |
| 38 |
|
| 39 |
protected function add_images_per_row_control( |
| 40 |
string $name = 'icons_per_row', |
| 41 |
$options = [ |
| 42 |
'2' => '2', |
| 43 |
'3' => '3', |
| 44 |
], |
| 45 |
string $default = '3', |
| 46 |
$label = '' |
| 47 |
): void { |
| 48 |
if ( ! $label ) { |
| 49 |
$label = esc_html__( 'Icons Per Row', 'elementor' ); |
| 50 |
} |
| 51 |
$this->add_control( |
| 52 |
$name, |
| 53 |
[ |
| 54 |
'label' => $label, |
| 55 |
'type' => Controls_Manager::SELECT, |
| 56 |
'options' => $options, |
| 57 |
'default' => $default, |
| 58 |
] |
| 59 |
); |
| 60 |
} |
| 61 |
|
| 62 |
protected function add_icons_per_row_control( |
| 63 |
string $name = 'icons_per_row', |
| 64 |
$options = [ |
| 65 |
'1' => '1', |
| 66 |
'2' => '2', |
| 67 |
'3' => '3', |
| 68 |
], |
| 69 |
string $default = '3', |
| 70 |
$label = '' |
| 71 |
): void { |
| 72 |
if ( ! $label ) { |
| 73 |
$label = esc_html__( 'Icons Per Row', 'elementor' ); |
| 74 |
} |
| 75 |
$this->add_control( |
| 76 |
$name, |
| 77 |
[ |
| 78 |
'label' => $label, |
| 79 |
'type' => Controls_Manager::SELECT, |
| 80 |
'options' => $options, |
| 81 |
'default' => $default, |
| 82 |
'selectors' => [ |
| 83 |
'{{WRAPPER}} .e-link-in-bio' => '--e-link-in-bio-icon-columns: {{VALUE}};', |
| 84 |
], |
| 85 |
] |
| 86 |
); |
| 87 |
} |
| 88 |
|
| 89 |
protected function add_slider_control( |
| 90 |
string $name, |
| 91 |
array $args = [] |
| 92 |
): void { |
| 93 |
$default_args = [ |
| 94 |
'type' => Controls_Manager::SLIDER, |
| 95 |
'default' => [ |
| 96 |
'unit' => 'px', |
| 97 |
], |
| 98 |
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ], |
| 99 |
'range' => [ |
| 100 |
'px' => [ |
| 101 |
'min' => 0, |
| 102 |
'max' => 100, |
| 103 |
'step' => 1, |
| 104 |
], |
| 105 |
], |
| 106 |
]; |
| 107 |
|
| 108 |
$this->add_control( |
| 109 |
$name, |
| 110 |
array_merge_recursive( $default_args, $args ) |
| 111 |
); |
| 112 |
} |
| 113 |
|
| 114 |
protected function add_borders_control( |
| 115 |
string $prefix, |
| 116 |
array $show_border_args = [], |
| 117 |
array $border_width_args = [], |
| 118 |
array $border_color_args = [] |
| 119 |
): void { |
| 120 |
$show_border = [ |
| 121 |
'label' => esc_html__( 'Border', 'elementor' ), |
| 122 |
'type' => Controls_Manager::SWITCHER, |
| 123 |
'label_on' => esc_html__( 'Yes', 'elementor' ), |
| 124 |
'label_off' => esc_html__( 'No', 'elementor' ), |
| 125 |
'return_value' => 'yes', |
| 126 |
'default' => '', |
| 127 |
]; |
| 128 |
|
| 129 |
$this->add_control( |
| 130 |
$prefix . '_show_border', |
| 131 |
array_merge( $show_border, $show_border_args ) |
| 132 |
); |
| 133 |
|
| 134 |
$condition = [ |
| 135 |
$prefix . '_show_border' => 'yes', |
| 136 |
]; |
| 137 |
|
| 138 |
if ( isset( $border_width_args['condition'] ) ) { |
| 139 |
$condition = array_merge( $condition, $border_width_args['condition'] ); |
| 140 |
unset( $border_width_args['condition'] ); |
| 141 |
} |
| 142 |
|
| 143 |
$border_width = [ |
| 144 |
'label' => esc_html__( 'Border Width', 'elementor' ) . ' (px)', |
| 145 |
'type' => Controls_Manager::SLIDER, |
| 146 |
'size_units' => [ 'px' ], |
| 147 |
'range' => [ |
| 148 |
'px' => $this->border_width_range, |
| 149 |
], |
| 150 |
'condition' => $condition, |
| 151 |
]; |
| 152 |
|
| 153 |
$this->add_control( |
| 154 |
$prefix . '_border_width', |
| 155 |
array_merge( $border_width, $border_width_args ), |
| 156 |
); |
| 157 |
|
| 158 |
$condition = [ |
| 159 |
$prefix . '_show_border' => 'yes', |
| 160 |
]; |
| 161 |
|
| 162 |
if ( isset( $border_color_args['condition'] ) ) { |
| 163 |
$condition = array_merge( $condition, $border_color_args['condition'] ); |
| 164 |
unset( $border_color_args['condition'] ); |
| 165 |
} |
| 166 |
|
| 167 |
$border_color = [ |
| 168 |
'label' => esc_html__( 'Border Color', 'elementor' ), |
| 169 |
'type' => Controls_Manager::COLOR, |
| 170 |
'condition' => $condition, |
| 171 |
]; |
| 172 |
|
| 173 |
$this->add_control( |
| 174 |
$prefix . '_border_color', |
| 175 |
array_merge( $border_color, $border_color_args ) |
| 176 |
); |
| 177 |
} |
| 178 |
|
| 179 |
protected function get_shape_divider( $side = 'bottom' ) { |
| 180 |
$settings = $this->settings; |
| 181 |
$base_setting_key = "identity_section_style_cover_divider_$side"; |
| 182 |
$file_name = $settings[ $base_setting_key ]; |
| 183 |
|
| 184 |
if ( empty( $file_name ) ) { |
| 185 |
return []; |
| 186 |
} |
| 187 |
|
| 188 |
$negative = ! empty( $settings[ $base_setting_key . '_negative' ] ); |
| 189 |
$shape_path = Shapes::get_shape_path( $file_name, $negative ); |
| 190 |
|
| 191 |
if ( ! is_file( $shape_path ) || ! is_readable( $shape_path ) ) { |
| 192 |
return []; |
| 193 |
} |
| 194 |
|
| 195 |
return [ |
| 196 |
'negative' => $negative, |
| 197 |
'svg' => Utils::file_get_contents( $shape_path ), |
| 198 |
]; |
| 199 |
} |
| 200 |
|
| 201 |
protected function print_shape_divider( $side = 'bottom' ) { |
| 202 |
$shape_divider = $this->get_shape_divider( $side ); |
| 203 |
|
| 204 |
if ( empty( $shape_divider ) ) { |
| 205 |
return; |
| 206 |
} |
| 207 |
?> |
| 208 |
<div |
| 209 |
class="elementor-shape elementor-shape-<?php echo esc_attr( $side ); ?>" |
| 210 |
data-negative="<?php |
| 211 |
echo esc_attr( $shape_divider['negative'] ? 'true' : 'false' ); |
| 212 |
?>" |
| 213 |
> |
| 214 |
<?php |
| 215 |
// PHPCS - The file content is being read from a strict file path structure. |
| 216 |
echo $shape_divider['svg']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 217 |
?> |
| 218 |
</div> |
| 219 |
<?php |
| 220 |
} |
| 221 |
} |
| 222 |
|