| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Paragraph; |
| 4 |
|
| 5 |
use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; |
| 6 |
use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 7 |
use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 8 |
use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control; |
| 9 |
use Elementor\Modules\AtomicWidgets\Elements\Has_Template; |
| 10 |
use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 11 |
use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_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\AtomicWidgets\Controls\Types\Text_Control; |
| 18 |
|
| 19 |
if ( ! defined( 'ABSPATH' ) ) { |
| 20 |
exit; |
| 21 |
} |
| 22 |
|
| 23 |
class Atomic_Paragraph extends Atomic_Widget_Base { |
| 24 |
use Has_Template; |
| 25 |
|
| 26 |
const LINK_BASE_STYLE_KEY = 'link-base'; |
| 27 |
|
| 28 |
public static function get_element_type(): string { |
| 29 |
return 'e-paragraph'; |
| 30 |
} |
| 31 |
|
| 32 |
public function get_title() { |
| 33 |
return esc_html__( 'Paragraph', 'elementor' ); |
| 34 |
} |
| 35 |
|
| 36 |
public function get_keywords() { |
| 37 |
return [ 'ato', 'atom', 'atoms', 'atomic' ]; |
| 38 |
} |
| 39 |
|
| 40 |
public function get_icon() { |
| 41 |
return 'eicon-paragraph'; |
| 42 |
} |
| 43 |
|
| 44 |
protected static function define_props_schema(): array { |
| 45 |
$props = [ |
| 46 |
'classes' => Classes_Prop_Type::make() |
| 47 |
->default( [] ), |
| 48 |
|
| 49 |
'paragraph' => String_Prop_Type::make() |
| 50 |
->default( __( 'Type your paragraph here', 'elementor' ) ), |
| 51 |
|
| 52 |
'link' => Link_Prop_Type::make(), |
| 53 |
|
| 54 |
'attributes' => Attributes_Prop_Type::make(), |
| 55 |
]; |
| 56 |
|
| 57 |
return $props; |
| 58 |
} |
| 59 |
|
| 60 |
protected function define_atomic_controls(): array { |
| 61 |
return [ |
| 62 |
Section::make() |
| 63 |
->set_label( __( 'Content', 'elementor' ) ) |
| 64 |
->set_items( [ |
| 65 |
Textarea_Control::bind_to( 'paragraph' ) |
| 66 |
->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ) |
| 67 |
->set_label( __( 'Paragraph', 'elementor' ) ), |
| 68 |
] ), |
| 69 |
Section::make() |
| 70 |
->set_label( __( 'Settings', 'elementor' ) ) |
| 71 |
->set_id( 'settings' ) |
| 72 |
->set_items( $this->get_settings_controls() ), |
| 73 |
]; |
| 74 |
} |
| 75 |
|
| 76 |
protected function get_settings_controls(): array { |
| 77 |
return [ |
| 78 |
Link_Control::bind_to( 'link' ) |
| 79 |
->set_label( __( 'Link', 'elementor' ) ), |
| 80 |
Text_Control::bind_to( '_cssid' ) |
| 81 |
->set_label( __( 'ID', 'elementor' ) ) |
| 82 |
->set_meta( $this->get_css_id_control_meta() ), |
| 83 |
]; |
| 84 |
} |
| 85 |
|
| 86 |
protected function define_base_styles(): array { |
| 87 |
$margin_value = Size_Prop_Type::generate( [ |
| 88 |
'unit' => 'px', |
| 89 |
'size' => 0 , |
| 90 |
] ); |
| 91 |
|
| 92 |
return [ |
| 93 |
'base' => Style_Definition::make() |
| 94 |
->add_variant( |
| 95 |
Style_Variant::make() |
| 96 |
->add_prop( 'margin', $margin_value ) |
| 97 |
), |
| 98 |
self::LINK_BASE_STYLE_KEY => Style_Definition::make() |
| 99 |
->add_variant( |
| 100 |
Style_Variant::make() |
| 101 |
->add_prop( 'all', 'unset' ) |
| 102 |
->add_prop( 'cursor', 'pointer' ) |
| 103 |
), |
| 104 |
]; |
| 105 |
} |
| 106 |
|
| 107 |
protected function get_templates(): array { |
| 108 |
return [ |
| 109 |
'elementor/elements/atomic-paragraph' => __DIR__ . '/atomic-paragraph.html.twig', |
| 110 |
]; |
| 111 |
} |
| 112 |
} |
| 113 |
|