← All changes
|
modules/atomic-widgets/elements/atomic-paragraph/atomic-paragraph.php
+29
-41
4.3.0-beta1
→
3.34.0-beta1
View file →
| @@ -1,17 +1,18 @@ | ||
| 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 | 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; | |
| 9 | +use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control; | |
| 10 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 11 | +use Elementor\Modules\AtomicWidgets\Module as Atomic_Widgets_Module; | |
| 11 | 12 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 12 | 13 | use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; |
| 13 | -use Elementor\Modules\AtomicWidgets\PropTypes\Escaped_Html_Prop_Type; | |
| 14 | +use Elementor\Modules\AtomicWidgets\PropTypes\Html_Prop_Type; | |
| 14 | 15 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 15 | 16 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 16 | 17 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 17 | 18 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| @@ -17,9 +18,9 @@ | ||
| 17 | 18 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 18 | 19 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 19 | 20 | use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; |
| 20 | 21 | use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control; |
| 21 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 22 | +use Elementor\Plugin; | |
| 22 | 23 | |
| 23 | 24 | if ( ! defined( 'ABSPATH' ) ) { |
| 24 | 25 | exit; |
| 25 | 26 | } |
| @@ -28,10 +29,8 @@ | ||
| 28 | 29 | use Has_Template; |
| 29 | 30 | |
| 30 | 31 | const LINK_BASE_STYLE_KEY = 'link-base'; |
| 31 | 32 | |
| 32 | - public static $widget_description = 'Display a paragraph with customizable tag, styles, and link options.'; | |
| 33 | - | |
| 34 | 33 | public static function get_element_type(): string { |
| 35 | 34 | return 'e-paragraph'; |
| 36 | 35 | } |
| 37 | 36 | |
| @@ -46,49 +45,49 @@ | ||
| 46 | 45 | public function get_icon() { |
| 47 | 46 | return 'eicon-paragraph'; |
| 48 | 47 | } |
| 49 | 48 | |
| 50 | - public static function html_tag_follows_link(): bool { | |
| 51 | - return false; | |
| 52 | - } | |
| 49 | + protected static function define_props_schema(): array { | |
| 50 | + $is_feature_active = Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_INLINE_EDITING ); | |
| 53 | 51 | |
| 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 | - } | |
| 52 | + $paragraph_prop = $is_feature_active | |
| 53 | + ? Html_Prop_Type::make()->default( __( 'Type your paragraph here', 'elementor' ) ) | |
| 54 | + : String_Prop_Type::make()->default( __( 'Type your paragraph here', 'elementor' ) ); | |
| 59 | 55 | |
| 60 | - protected static function define_props_schema(): array { | |
| 61 | - return [ | |
| 56 | + $props = [ | |
| 62 | 57 | 'classes' => Classes_Prop_Type::make() |
| 63 | 58 | ->default( [] ), |
| 64 | 59 | |
| 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' ), | |
| 60 | + 'paragraph' => $paragraph_prop | |
| 61 | + ->description( 'The text content of the paragraph.' ), | |
| 69 | 62 | |
| 70 | 63 | 'tag' => String_Prop_Type::make() |
| 71 | 64 | ->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.' ), | |
| 65 | + ->default( 'p' ), | |
| 74 | 66 | |
| 75 | 67 | 'link' => Link_Prop_Type::make(), |
| 76 | 68 | |
| 77 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 69 | + 'attributes' => Attributes_Prop_Type::make(), | |
| 78 | 70 | ]; |
| 71 | + | |
| 72 | + return $props; | |
| 79 | 73 | } |
| 80 | 74 | |
| 81 | 75 | protected function define_atomic_controls(): array { |
| 76 | + $is_feature_active = Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_INLINE_EDITING ); | |
| 77 | + | |
| 78 | + $control = $is_feature_active | |
| 79 | + ? Inline_Editing_Control::bind_to( 'paragraph' ) | |
| 80 | + ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ) | |
| 81 | + ->set_label( __( 'Paragraph', 'elementor' ) ) | |
| 82 | + : Textarea_Control::bind_to( 'paragraph' ) | |
| 83 | + ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ) | |
| 84 | + ->set_label( __( 'Paragraph', 'elementor' ) ); | |
| 85 | + | |
| 82 | 86 | return [ |
| 83 | 87 | Section::make() |
| 84 | 88 | ->set_label( __( 'Content', 'elementor' ) ) |
| 85 | - ->set_id( 'content' ) | |
| 86 | - ->set_items( [ | |
| 87 | - Inline_Editing_Control::bind_to( 'paragraph' ) | |
| 88 | - ->set_placeholder( __( 'Type your paragraph here', 'elementor' ) ) | |
| 89 | - ->set_label( __( 'Paragraph', 'elementor' ) ), | |
| 90 | - ] ), | |
| 89 | + ->set_items( [ $control ] ), | |
| 91 | 90 | Section::make() |
| 92 | 91 | ->set_label( __( 'Settings', 'elementor' ) ) |
| 93 | 92 | ->set_id( 'settings' ) |
| 94 | 93 | ->set_items( $this->get_settings_controls() ), |
| @@ -145,17 +144,6 @@ | ||
| 145 | 144 | protected function get_templates(): array { |
| 146 | 145 | return [ |
| 147 | 146 | 'elementor/elements/atomic-paragraph' => __DIR__ . '/atomic-paragraph.html.twig', |
| 148 | 147 | ]; |
| 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 | 148 | } |
| 161 | 149 | } |