static::html_tag_follows_link(), ] ); } protected static function define_props_schema(): array { return [ 'classes' => Classes_Prop_Type::make() ->default( [] ), 'tag' => String_Prop_Type::make() ->enum( [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] ) ->default( 'h2' ) ->description( 'The HTML tag for the heading element. One of: h1, h2, h3, h4, h5, or h6. Do not use p, span, or div.' ), 'title' => Escaped_Html_Prop_Type::make() ->default( __( 'This is a title', 'elementor' ) ) ->description( 'The text content of the heading.' ) ->alias( 'text', 'content', 'heading' ), 'link' => Link_Prop_Type::make(), 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), ]; } protected function define_atomic_controls(): array { $content_section = Section::make() ->set_label( __( 'Content', 'elementor' ) ) ->set_id( 'content' ) ->set_items( [ Inline_Editing_Control::bind_to( 'title' ) ->set_placeholder( __( 'Type your title here', 'elementor' ) ) ->set_label( __( 'Title', 'elementor' ) ), ] ); return [ $content_section, Section::make() ->set_label( __( 'Settings', 'elementor' ) ) ->set_id( 'settings' ) ->set_items( $this->get_settings_controls() ), ]; } protected function get_settings_controls(): array { return [ Select_Control::bind_to( 'tag' ) ->set_options([ [ 'value' => 'h1', 'label' => 'H1', ], [ 'value' => 'h2', 'label' => 'H2', ], [ 'value' => 'h3', 'label' => 'H3', ], [ 'value' => 'h4', 'label' => 'H4', ], [ 'value' => 'h5', 'label' => 'H5', ], [ 'value' => 'h6', 'label' => 'H6', ], ]) ->set_label( __( 'Tag', 'elementor' ) ), Link_Control::bind_to( 'link' ) ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) ->set_label( __( 'Link', 'elementor' ) ) ->set_meta( [ 'topDivider' => true, ] ), Text_Control::bind_to( '_cssid' ) ->set_label( __( 'ID', 'elementor' ) ) ->set_meta( $this->get_css_id_control_meta() ), ]; } protected function define_base_styles(): array { $margin_value = Size_Prop_Type::generate( [ 'unit' => 'px', 'size' => 0 , ] ); return [ 'base' => Style_Definition::make() ->add_variant( Style_Variant::make() ->add_prop( 'margin', $margin_value ) ), self::LINK_BASE_STYLE_KEY => Style_Definition::make() ->add_variant( Style_Variant::make() ->add_prop( 'all', 'unset' ) ->add_prop( 'cursor', 'pointer' ) ), ]; } protected function get_templates(): array { return [ 'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig', ]; } public function render_markdown(): string { $settings = $this->get_atomic_settings(); $title = wp_strip_all_tags( $settings['title'] ?? '' ); if ( empty( $title ) ) { return ''; } $tag = $settings['tag'] ?? 'h2'; $level_map = [ 'h1' => 1, 'h2' => 2, 'h3' => 3, 'h4' => 4, 'h5' => 5, 'h6' => 6, ]; $level = $level_map[ $tag ] ?? 2; $md = str_repeat( '#', $level ) . ' ' . $title; if ( ! empty( $settings['link']['href'] ) ) { $md = str_repeat( '#', $level ) . ' [' . $title . '](' . esc_url( $settings['link']['href'] ) . ')'; } return $md; } }