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