| 1 |
<?php |
| 2 |
namespace MasterAddons\Inc\Admin\WidgetBuilder\Controls; |
| 3 |
|
| 4 |
use MasterAddons\Inc\Admin\WidgetBuilder\Controls\Control_Base; |
| 5 |
|
| 6 |
defined('ABSPATH') || exit; |
| 7 |
|
| 8 |
/** |
| 9 |
* DIVIDER Control |
| 10 |
* Handles Elementor DIVIDER control type |
| 11 |
* Visual divider/separator between controls |
| 12 |
* |
| 13 |
* Supported properties: |
| 14 |
* - label: Optional label for the divider |
| 15 |
* - name: Field name (used for control key) |
| 16 |
* - style: Divider style (default, thick, double) |
| 17 |
* |
| 18 |
* Common settings (handled by base class): |
| 19 |
* - separator: Control separator position |
| 20 |
* - condition: Conditional display logic |
| 21 |
* |
| 22 |
* Note: DIVIDER is a visual separator, it doesn't store any value |
| 23 |
*/ |
| 24 |
class Divider extends Control_Base { |
| 25 |
|
| 26 |
public function get_type() { |
| 27 |
return 'DIVIDER'; |
| 28 |
} |
| 29 |
|
| 30 |
public function build($control_key, $field) { |
| 31 |
// Check if responsive control |
| 32 |
$is_responsive = isset($field['responsive']) && $field['responsive']; |
| 33 |
|
| 34 |
// Build control header without label for divider |
| 35 |
$content = "\t\t\$this->add_control(\n"; |
| 36 |
$content .= "\t\t\t'{$control_key}',\n"; |
| 37 |
$content .= "\t\t\t[\n"; |
| 38 |
$content .= "\t\t\t\t'type' => Controls_Manager::DIVIDER,\n"; |
| 39 |
|
| 40 |
// Style property |
| 41 |
if (!empty($field['style'])) { |
| 42 |
$content .= "\t\t\t\t'style' => '" . esc_js($field['style']) . "',\n"; |
| 43 |
} |
| 44 |
|
| 45 |
// Add common properties (separator, condition) |
| 46 |
$content .= $this->build_common_properties($field); |
| 47 |
|
| 48 |
// Close control |
| 49 |
$content .= "\t\t\t]\n"; |
| 50 |
$content .= "\t\t);\n\n"; |
| 51 |
|
| 52 |
return $content; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* DIVIDER has no label and is never responsive (mirrors build()). |
| 57 |
*/ |
| 58 |
public function get_config($control_key, $field) { |
| 59 |
$args = ['type' => $this->type_constant()]; |
| 60 |
if (!empty($field['style'])) { |
| 61 |
$args['style'] = $field['style']; |
| 62 |
} |
| 63 |
$args = array_merge($args, $this->get_common_config($field)); |
| 64 |
|
| 65 |
return [ |
| 66 |
'key' => $control_key, |
| 67 |
'responsive' => false, |
| 68 |
'args' => $args, |
| 69 |
]; |
| 70 |
} |
| 71 |
} |
| 72 |
|