| 1 |
<?php |
| 2 |
namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Heading; |
| 3 |
|
| 4 |
use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 5 |
use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 6 |
use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control; |
| 7 |
use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control; |
| 8 |
use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; |
| 9 |
use Elementor\Modules\AtomicWidgets\Elements\Has_Template; |
| 10 |
use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 11 |
use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type; |
| 12 |
use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 13 |
use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 14 |
use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 15 |
use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 16 |
use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 17 |
use Elementor\Modules\WpRest\Classes\WP_Post; |
| 18 |
|
| 19 |
if ( ! defined( 'ABSPATH' ) ) { |
| 20 |
exit; // Exit if accessed directly. |
| 21 |
} |
| 22 |
|
| 23 |
class Atomic_Heading extends Atomic_Widget_Base { |
| 24 |
use Has_Template; |
| 25 |
|
| 26 |
public static function get_element_type(): string { |
| 27 |
return 'a-heading'; |
| 28 |
} |
| 29 |
|
| 30 |
public function get_title() { |
| 31 |
return esc_html__( 'Atomic Heading', 'elementor' ); |
| 32 |
} |
| 33 |
|
| 34 |
public function get_icon() { |
| 35 |
return 'eicon-e-heading'; |
| 36 |
} |
| 37 |
|
| 38 |
protected static function define_props_schema(): array { |
| 39 |
return [ |
| 40 |
'classes' => Classes_Prop_Type::make() |
| 41 |
->default( [] ), |
| 42 |
|
| 43 |
'tag' => String_Prop_Type::make() |
| 44 |
->enum( [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] ) |
| 45 |
->default( 'h2' ), |
| 46 |
|
| 47 |
'title' => String_Prop_Type::make() |
| 48 |
->default( __( 'Your Title Here', 'elementor' ) ), |
| 49 |
|
| 50 |
'link' => Link_Prop_Type::make(), |
| 51 |
]; |
| 52 |
} |
| 53 |
|
| 54 |
protected function define_atomic_controls(): array { |
| 55 |
return [ |
| 56 |
Section::make() |
| 57 |
->set_label( __( 'Content', 'elementor' ) ) |
| 58 |
->set_items( [ |
| 59 |
Textarea_Control::bind_to( 'title' ) |
| 60 |
->set_label( __( 'Title', 'elementor' ) ) |
| 61 |
->set_placeholder( __( 'Type your title here', 'elementor' ) ), |
| 62 |
Select_Control::bind_to( 'tag' ) |
| 63 |
->set_label( esc_html__( 'Tag', 'elementor' ) ) |
| 64 |
->set_options( [ |
| 65 |
[ |
| 66 |
'value' => 'h1', |
| 67 |
'label' => 'H1', |
| 68 |
], |
| 69 |
[ |
| 70 |
'value' => 'h2', |
| 71 |
'label' => 'H2', |
| 72 |
], |
| 73 |
[ |
| 74 |
'value' => 'h3', |
| 75 |
'label' => 'H3', |
| 76 |
], |
| 77 |
[ |
| 78 |
'value' => 'h4', |
| 79 |
'label' => 'H4', |
| 80 |
], |
| 81 |
[ |
| 82 |
'value' => 'h5', |
| 83 |
'label' => 'H5', |
| 84 |
], |
| 85 |
[ |
| 86 |
'value' => 'h6', |
| 87 |
'label' => 'H6', |
| 88 |
], |
| 89 |
]), |
| 90 |
Link_Control::bind_to( 'link' ), |
| 91 |
] ), |
| 92 |
]; |
| 93 |
} |
| 94 |
|
| 95 |
protected function define_base_styles(): array { |
| 96 |
$color_value = Color_Prop_Type::generate( 'black' ); |
| 97 |
$font_family_value = String_Prop_Type::generate( 'Inter' ); |
| 98 |
$font_size_value = Size_Prop_Type::generate( [ |
| 99 |
'size' => 3, |
| 100 |
'unit' => 'rem', |
| 101 |
] ); |
| 102 |
$line_height_value = String_Prop_Type::generate( '1.1' ); |
| 103 |
$font_weight_value = String_Prop_Type::generate( '600' ); |
| 104 |
|
| 105 |
return [ |
| 106 |
'base' => Style_Definition::make() |
| 107 |
->add_variant( |
| 108 |
Style_Variant::make() |
| 109 |
->add_prop( 'color', $color_value ) |
| 110 |
->add_prop( 'font-family', $font_family_value ) |
| 111 |
->add_prop( 'font-size', $font_size_value ) |
| 112 |
->add_prop( 'line-height', $line_height_value ) |
| 113 |
->add_prop( 'font-weight', $font_weight_value ) |
| 114 |
), |
| 115 |
]; |
| 116 |
} |
| 117 |
|
| 118 |
protected function get_templates(): array { |
| 119 |
return [ |
| 120 |
'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig', |
| 121 |
]; |
| 122 |
} |
| 123 |
} |
| 124 |
|