| 1 |
<?php |
| 2 |
|
| 3 |
namespace HelloPlus\Classes; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
use Elementor\{ |
| 10 |
Controls_Manager, |
| 11 |
Widget_Base |
| 12 |
}; |
| 13 |
|
| 14 |
use HelloPlus\Modules\Content\Classes\{ |
| 15 |
Choose_Img_Control, |
| 16 |
}; |
| 17 |
|
| 18 |
class Ehp_Column_Structure { |
| 19 |
private $context = []; |
| 20 |
private ?Widget_Base $widget = null; |
| 21 |
private array $condition = []; |
| 22 |
private string $separator = ''; |
| 23 |
|
| 24 |
public function set_context( array $context ) { |
| 25 |
$this->context = $context; |
| 26 |
} |
| 27 |
|
| 28 |
public function add_column_structure_attributes() { |
| 29 |
$widget_settings = $this->widget->get_settings_for_display(); |
| 30 |
|
| 31 |
if ( empty( $widget_settings['layout_column_structure'] ) ) { |
| 32 |
return; |
| 33 |
} |
| 34 |
|
| 35 |
$this->widget->add_render_attribute( $this->context['render_attribute'], [ |
| 36 |
'class' => [ |
| 37 |
'has-column-structure-' . $widget_settings['layout_column_structure'], |
| 38 |
'yes' === $widget_settings['layout_reverse_structure'] ? 'is-reverse' : '', |
| 39 |
], |
| 40 |
] ); |
| 41 |
} |
| 42 |
|
| 43 |
public function add_style_controls() { |
| 44 |
$this->widget->add_control( |
| 45 |
'layout_column_structure', |
| 46 |
[ |
| 47 |
'label' => esc_html__( 'Column Structure', 'hello-plus' ), |
| 48 |
'type' => Choose_Img_Control::CONTROL_NAME, |
| 49 |
'default' => '50-50', |
| 50 |
'label_block' => true, |
| 51 |
'columns' => 2, |
| 52 |
'toggle' => false, |
| 53 |
'options' => [ |
| 54 |
'50-50' => [ |
| 55 |
'title' => esc_html__( '50:50', 'hello-plus' ), |
| 56 |
'image' => HELLOPLUS_IMAGES_URL . 'column-50-50.svg', |
| 57 |
'hover_image' => true, |
| 58 |
], |
| 59 |
'33-66' => [ |
| 60 |
'title' => esc_html__( '33:66', 'hello-plus' ), |
| 61 |
'image' => HELLOPLUS_IMAGES_URL . 'column-33-66.svg', |
| 62 |
'hover_image' => true, |
| 63 |
], |
| 64 |
'25-75' => [ |
| 65 |
'title' => esc_html__( '25:75', 'hello-plus' ), |
| 66 |
'image' => HELLOPLUS_IMAGES_URL . 'column-25-75.svg', |
| 67 |
'hover_image' => true, |
| 68 |
], |
| 69 |
], |
| 70 |
'frontend_available' => true, |
| 71 |
'separator' => $this->separator, |
| 72 |
'condition' => $this->condition, |
| 73 |
] |
| 74 |
); |
| 75 |
|
| 76 |
$this->widget->add_control( |
| 77 |
'layout_reverse_structure', |
| 78 |
[ |
| 79 |
'label' => esc_html__( 'Reverse Structure', 'hello-plus' ), |
| 80 |
'type' => Controls_Manager::SWITCHER, |
| 81 |
'label_on' => esc_html__( 'Yes', 'hello-plus' ), |
| 82 |
'label_off' => esc_html__( 'No', 'hello-plus' ), |
| 83 |
'return_value' => 'yes', |
| 84 |
'frontend_available' => true, |
| 85 |
'default' => '', |
| 86 |
'condition' => array_merge( $this->condition, [ |
| 87 |
'layout_column_structure!' => '50-50', |
| 88 |
] ), |
| 89 |
] |
| 90 |
); |
| 91 |
} |
| 92 |
|
| 93 |
public function __construct( Widget_Base $widget, $context = [] ) { |
| 94 |
$this->widget = $widget; |
| 95 |
$this->context = $context; |
| 96 |
$this->condition = $this->context['condition'] ?? []; |
| 97 |
$this->separator = $this->context['separator'] ?? ''; |
| 98 |
} |
| 99 |
} |
| 100 |
|