← All changes
|
modules/atomic-widgets/elements/atomic-paragraph/atomic-paragraph.php
+23
-94
4.3.0-beta1
→
3.28.0-dev2
View file →
| @@ -1,25 +1,21 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Paragraph; |
| 4 | 4 | |
| 5 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base; | |
| 5 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; | |
| 6 | 6 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 7 | 7 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 8 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control; | |
| 9 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template; | |
| 10 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer; | |
| 8 | +use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control; | |
| 9 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 11 | 10 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 12 | -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; | |
| 13 | -use Elementor\Modules\AtomicWidgets\PropTypes\Escaped_Html_Prop_Type; | |
| 11 | +use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type; | |
| 14 | 12 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 15 | 13 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 16 | 14 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 17 | 15 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 18 | 16 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 19 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; | |
| 20 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control; | |
| 21 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 17 | +use Elementor\Modules\WpRest\Classes\WP_Post; | |
| 22 | 18 | |
| 23 | 19 | if ( ! defined( 'ABSPATH' ) ) { |
| 24 | 20 | exit; |
| 25 | 21 | } |
| @@ -26,56 +22,29 @@ | ||
| 26 | 22 | |
| 27 | 23 | class Atomic_Paragraph extends Atomic_Widget_Base { |
| 28 | 24 | use Has_Template; |
| 29 | 25 | |
| 30 | - const LINK_BASE_STYLE_KEY = 'link-base'; | |
| 31 | - | |
| 32 | - public static $widget_description = 'Display a paragraph with customizable tag, styles, and link options.'; | |
| 33 | - | |
| 34 | 26 | public static function get_element_type(): string { |
| 35 | - return 'e-paragraph'; | |
| 27 | + return 'a-paragraph'; | |
| 36 | 28 | } |
| 37 | 29 | |
| 38 | 30 | public function get_title() { |
| 39 | - return esc_html__( 'Paragraph', 'elementor' ); | |
| 31 | + return esc_html__( 'Atomic Paragraph', 'elementor' ); | |
| 40 | 32 | } |
| 41 | 33 | |
| 42 | - public function get_keywords() { | |
| 43 | - return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 44 | - } | |
| 45 | - | |
| 46 | 34 | public function get_icon() { |
| 47 | 35 | return 'eicon-paragraph'; |
| 48 | 36 | } |
| 49 | 37 | |
| 50 | - public static function html_tag_follows_link(): bool { | |
| 51 | - return false; | |
| 52 | - } | |
| 53 | - | |
| 54 | - public static function get_computed_html_tag( array $settings ): string { | |
| 55 | - return Html_Tag_Computer::compute( $settings, 'p', [ | |
| 56 | - Html_Tag_Computer::FOLLOW_LINK_OPTION => static::html_tag_follows_link(), | |
| 57 | - ] ); | |
| 58 | - } | |
| 59 | - | |
| 60 | 38 | protected static function define_props_schema(): array { |
| 61 | 39 | return [ |
| 62 | 40 | 'classes' => Classes_Prop_Type::make() |
| 63 | 41 | ->default( [] ), |
| 64 | 42 | |
| 65 | - 'paragraph' => Escaped_Html_Prop_Type::make() | |
| 66 | - ->default( __( 'Type your paragraph here', 'elementor' ) ) | |
| 67 | - ->description( 'The text content of the paragraph.' ) | |
| 68 | - ->alias( 'text', 'content' ), | |
| 43 | + 'paragraph' => String_Prop_Type::make() | |
| 44 | + ->default( __( 'Type your paragraph here', 'elementor' ) ), | |
| 69 | 45 | |
| 70 | - 'tag' => String_Prop_Type::make() | |
| 71 | - ->enum( [ 'p', 'span' ] ) | |
| 72 | - ->default( 'p' ) | |
| 73 | - ->description( 'The HTML tag for the paragraph element. One of: p or span. Do not use heading or div tags.' ), | |
| 74 | - | |
| 75 | 46 | 'link' => Link_Prop_Type::make(), |
| 76 | - | |
| 77 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 78 | 47 | ]; |
| 79 | 48 | } |
| 80 | 49 | |
| 81 | 50 | protected function define_atomic_controls(): array { |
| @@ -81,65 +50,36 @@ | ||
| 81 | 50 | protected function define_atomic_controls(): array { |
| 82 | 51 | return [ |
| 83 | 52 | Section::make() |
| 84 | 53 | ->set_label( __( 'Content', 'elementor' ) ) |
| 85 | - ->set_id( 'content' ) | |
| 86 | 54 | ->set_items( [ |
| 87 | - Inline_Editing_Control::bind_to( 'paragraph' ) | |
| 88 | - ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ) | |
| 89 | - ->set_label( __( 'Paragraph', 'elementor' ) ), | |
| 90 | - ] ), | |
| 91 | - Section::make() | |
| 92 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 93 | - ->set_id( 'settings' ) | |
| 94 | - ->set_items( $this->get_settings_controls() ), | |
| 95 | - ]; | |
| 96 | - } | |
| 55 | + Textarea_Control::bind_to( 'paragraph' ) | |
| 56 | + ->set_label( __( 'Paragraph', 'elementor' ) ) | |
| 57 | + ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ), | |
| 97 | 58 | |
| 98 | - protected function get_settings_controls(): array { | |
| 99 | - return [ | |
| 100 | - Select_Control::bind_to( 'tag' ) | |
| 101 | - ->set_options([ | |
| 102 | - [ | |
| 103 | - 'value' => 'p', | |
| 104 | - 'label' => 'p', | |
| 105 | - ], | |
| 106 | - [ | |
| 107 | - 'value' => 'span', | |
| 108 | - 'label' => 'span', | |
| 109 | - ], | |
| 110 | - ]) | |
| 111 | - ->set_label( __( 'Tag', 'elementor' ) ), | |
| 112 | - Link_Control::bind_to( 'link' ) | |
| 113 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 114 | - ->set_label( __( 'Link', 'elementor' ) ) | |
| 115 | - ->set_meta( [ | |
| 116 | - 'topDivider' => true, | |
| 59 | + Link_Control::bind_to( 'link' ), | |
| 117 | 60 | ] ), |
| 118 | - Text_Control::bind_to( '_cssid' ) | |
| 119 | - ->set_label( __( 'ID', 'elementor' ) ) | |
| 120 | - ->set_meta( $this->get_css_id_control_meta() ), | |
| 121 | 61 | ]; |
| 122 | 62 | } |
| 123 | 63 | |
| 124 | 64 | protected function define_base_styles(): array { |
| 125 | - $margin_value = Size_Prop_Type::generate( [ | |
| 126 | - 'unit' => 'px', | |
| 127 | - 'size' => 0 , | |
| 65 | + $color_value = Color_Prop_Type::generate( 'black' ); | |
| 66 | + $font_family_value = String_Prop_Type::generate( 'Poppins' ); | |
| 67 | + $font_size_value = Size_Prop_Type::generate( [ | |
| 68 | + 'size' => 1.2, | |
| 69 | + 'unit' => 'rem', | |
| 128 | 70 | ] ); |
| 71 | + $line_height_value = String_Prop_Type::generate( '1.5' ); | |
| 129 | 72 | |
| 130 | 73 | return [ |
| 131 | 74 | 'base' => Style_Definition::make() |
| 132 | 75 | ->add_variant( |
| 133 | 76 | Style_Variant::make() |
| 134 | - ->add_prop( 'margin', $margin_value ) | |
| 77 | + ->add_prop( 'color', $color_value ) | |
| 78 | + ->add_prop( 'font-family', $font_family_value ) | |
| 79 | + ->add_prop( 'font-size', $font_size_value ) | |
| 80 | + ->add_prop( 'line-height', $line_height_value ) | |
| 135 | 81 | ), |
| 136 | - self::LINK_BASE_STYLE_KEY => Style_Definition::make() | |
| 137 | - ->add_variant( | |
| 138 | - Style_Variant::make() | |
| 139 | - ->add_prop( 'all', 'unset' ) | |
| 140 | - ->add_prop( 'cursor', 'pointer' ) | |
| 141 | - ), | |
| 142 | 82 | ]; |
| 143 | 83 | } |
| 144 | 84 | |
| 145 | 85 | protected function get_templates(): array { |
| @@ -145,17 +85,6 @@ | ||
| 145 | 85 | protected function get_templates(): array { |
| 146 | 86 | return [ |
| 147 | 87 | 'elementor/elements/atomic-paragraph' => __DIR__ . '/atomic-paragraph.html.twig', |
| 148 | 88 | ]; |
| 149 | - } | |
| 150 | - | |
| 151 | - public function render_markdown(): string { | |
| 152 | - $settings = $this->get_atomic_settings(); | |
| 153 | - $content = $settings['paragraph'] ?? ''; | |
| 154 | - | |
| 155 | - if ( empty( $content ) ) { | |
| 156 | - return ''; | |
| 157 | - } | |
| 158 | - | |
| 159 | - return \Elementor\Modules\MarkdownRender\Html_To_Markdown::convert( $content ); | |
| 160 | 89 | } |
| 161 | 90 | } |