33
44use Elementor \Widget_Base ;
55use Elementor \Controls_Manager ;
6+ use Elementor \Group_Control_Image_Size ;
67use Elementor \Utils as Utils ;
78use Elementor \Repeater as Repeater ;
89use Elementor \Group_Control_Typography ;
910use Elementor \Group_Control_Border ;
10- use Elementor \Group_Control_Image_Size ;
1111
1212if ( ! defined ( 'ABSPATH ' ) ) exit ; // Exit if accessed directly
1313
@@ -120,10 +120,9 @@ protected function register_controls() {
120120 $ this ->add_group_control (
121121 Group_Control_Image_Size::get_type (),
122122 [
123- 'name ' => 'how_to_image_size ' ,
124- 'exclude ' => [ 'custom ' ],
125- 'include ' => [],
126- 'default ' => 'large ' ,
123+ 'name ' => 'image_size ' ,
124+ 'label ' => __ ( 'Image Size ' , 'mighty ' ),
125+ 'default ' => 'full ' ,
127126 ]
128127 );
129128
@@ -134,11 +133,6 @@ protected function register_controls() {
134133 'type ' => Controls_Manager::URL ,
135134 'placeholder ' => __ ( 'https://your-link.com ' , 'mighty ' ),
136135 'show_external ' => true ,
137- 'default ' => [
138- 'url ' => '' ,
139- 'is_external ' => true ,
140- 'nofollow ' => true ,
141- ],
142136 'dynamic ' => [ 'active ' => true ],
143137 ]
144138 );
@@ -705,9 +699,6 @@ protected function register_controls() {
705699 ],
706700 'default ' => 'center ' ,
707701 'toggle ' => true ,
708- 'selectors ' => [
709- '{{WRAPPER}} .mt-how-to-step ' => 'align-items: {{VALUE}} ' ,
710- ],
711702 ]
712703 );
713704
@@ -717,15 +708,15 @@ protected function register_controls() {
717708 'label ' => __ ( 'Vertical Alignment ' , 'mighty ' ),
718709 'type ' => Controls_Manager::CHOOSE ,
719710 'options ' => [
720- 'top ' => [
711+ 'flex-start ' => [
721712 'title ' => __ ( 'Top ' , 'mighty ' ),
722713 'icon ' => 'eicon-v-align-top ' ,
723714 ],
724- 'middle ' => [
715+ 'center ' => [
725716 'title ' => __ ( 'Middle ' , 'mighty ' ),
726717 'icon ' => ' eicon-v-align-middle ' ,
727718 ],
728- 'bottom ' => [
719+ 'flex-end ' => [
729720 'title ' => __ ( 'Bottom ' , 'mighty ' ),
730721 'icon ' => 'eicon-v-align-bottom ' ,
731722 ],
@@ -736,9 +727,6 @@ protected function register_controls() {
736727 ],
737728 'default ' => 'middle ' ,
738729 'toggle ' => true ,
739- 'selectors ' => [
740- '{{WRAPPER}} .mt-how-to-step ' => 'align-items: {{VALUES}} '
741- ]
742730 ]
743731 );
744732
@@ -2252,7 +2240,7 @@ protected function register_controls() {
22522240 'default ' => 'center ' ,
22532241 'toggle ' => true ,
22542242 'selectors ' => [
2255- '{{WRAPPER}} .mt-how-to-step ' => 'align-items: {{VALUES}} '
2243+ '{{WRAPPER}} .mt-how-to-step-image ' => 'align-items: {{VALUES}} '
22562244 ]
22572245 ]
22582246 );
@@ -2282,7 +2270,7 @@ protected function register_controls() {
22822270 'default ' => 'center ' ,
22832271 'toggle ' => true ,
22842272 'selectors ' => [
2285- '{{WRAPPER}} .mt-how-to-step ' => 'align-items: {{VALUES}} '
2273+ '{{WRAPPER}} .mt-how-to-step-image ' => 'align-items: {{VALUES}} '
22862274 ]
22872275 ]
22882276 );
@@ -2393,7 +2381,7 @@ protected function get_how_to_json_ld() {
23932381 }
23942382
23952383 if ( ! empty ( $ how_to_image ['url ' ] ) ) {
2396- $ image_url = Group_Control_Image_Size::get_attachment_image_src ( $ how_to_image ['id ' ], 'how_to_image_size ' , $ settings );
2384+ $ image_url = Group_Control_Image_Size::get_attachment_image_src ( strval ( $ how_to_image ['id ' ]) , 'image_size ' , $ settings );
23972385 };
23982386 ?>
23992387 <script type="application/ld+json">
@@ -2483,10 +2471,10 @@ protected function render()
24832471
24842472 if ( !empty ($ settings ['how_to_image_link ' ]['url ' ] ) ) {
24852473 $ how_to_image_link = $ settings ['how_to_image_link ' ]['url ' ];
2486- } else {
2487- $ how_to_image_link = "javascript:void(0) " ;
24882474 }
24892475
2476+ $ image_url = Group_Control_Image_Size::get_attachment_image_src ( strval ($ settings ['how_to_image ' ]['id ' ]), 'image_size ' , $ settings );
2477+
24902478 if ( $ settings ['how_to_total_time ' ] == 'yes ' ) {
24912479 $ total_time = $ settings ['how_to_total_time_text ' ];
24922480
@@ -2528,6 +2516,8 @@ protected function render()
25282516 $ this ->add_render_attribute ( 'mt-how-to-tools-title ' , 'class ' , 'mt-how-to-tools-title ' );
25292517 $ this ->add_render_attribute ( 'mt-how-to-step-title ' , 'class ' , 'mt-how-to-step-title ' );
25302518 $ this ->add_render_attribute ( 'mt-how-to-step-section-title ' , 'class ' , 'mt-how-to-step-section-title ' );
2519+ $ this ->add_render_attribute ( 'mt-how-to-step-image ' , 'class ' , 'mt-how-to-step-image ' );
2520+ $ this ->add_render_attribute ( 'mt-how-to-step-content ' , 'class ' , 'mt-how-to-step-content ' );
25312521
25322522 ?>
25332523
@@ -2537,7 +2527,13 @@ protected function render()
25372527 <?php $ this ->get_how_to_json_ld (); ?>
25382528 <?php } ?>
25392529 <?php if ( !empty ( $ settings ['how_to_title ' ] ) ) { ?>
2540- <<?php echo $ settings ['title_html_tag ' ]?> <?php echo $ this ->get_render_attribute_string ('mt-how-to-title ' ); ?> ><?php echo $ settings ['how_to_title ' ]; ?> </<?php echo $ settings ['title_html_tag ' ]?> >
2530+ <?php if ( !empty ($ how_to_image_link ) ) { ?>
2531+ <a href="<?php echo $ how_to_image_link ;?> ">
2532+ <?php } ?>
2533+ <<?php echo $ settings ['title_html_tag ' ]?> <?php echo $ this ->get_render_attribute_string ('mt-how-to-title ' ); ?> ><?php echo $ settings ['how_to_title ' ]; ?> </<?php echo $ settings ['title_html_tag ' ]?> >
2534+ <?php if ( !empty ($ how_to_image_link ) ) { ?>
2535+ </a>
2536+ <?php } ?>
25412537 <?php } ?>
25422538
25432539 <?php if ( !empty ( $ settings ['how_to_subtitle ' ] ) ) { ?>
@@ -2549,11 +2545,9 @@ protected function render()
25492545 <?php } ?>
25502546
25512547 <?php if ( !empty ( $ settings ['how_to_image ' ]['url ' ] ) ) { ?>
2552- <a href="<?php echo $ how_to_image_link ;?> ">
25532548 <div class="mt-how-to-image">
2554- <?php echo Group_Control_Image_Size:: get_attachment_image_html ( $ settings , ' how_to_image_size ' , ' how_to_image ' ) ; ?>
2549+ <img src= < ?php echo $ image_url ; ?> >
25552550 </div>
2556- </a>
25572551 <?php } ?>
25582552
25592553 <!-- Advanced Options -->
@@ -2605,16 +2599,30 @@ protected function render()
26052599 <p class="mt-how-to-step-section-sub-title"><?php echo $ settings ['steps_description ' ];?> </p>
26062600
26072601 <?php foreach ( $ settings ['step_list ' ] as $ key => $ value ) { ?>
2602+
2603+ <php print_r($value); ?>
26082604
26092605 <?php if ( $ value ['image_position ' ] == 'custom ' ) { ?>
2606+
2607+ <?php if ( $ value ['image_alignment ' ] == 'left ' || $ value ['image_alignment ' ] == 'right ' ) {
2608+
2609+ $ this ->add_render_attribute ( 'mt-how-to-step-image ' , 'style ' , 'align-self: ' .$ value ['vertical_alignment ' ].'; ' );
2610+ }
2611+
2612+ if ( $ value ['image_alignment ' ] == 'top ' || $ value ['image_alignment ' ] == 'bottom ' ) {
2613+
2614+ $ this ->add_render_attribute ( 'mt-how-to-step-image ' , 'style ' , 'align-self: ' .$ value ['horizontal_alignment ' ].'; ' );
2615+
2616+ } ?>
2617+
26102618 <div class="mt-how-to-step mt-has-img mt-step-img-<?php echo $ value ['image_alignment ' ];?> " >
26112619 <?php } else { ?>
26122620 <div class="mt-how-to-step mt-has-img mt-step-img-<?php echo $ settings ['step_image_alignment ' ];?> " >
26132621 <?php } ?>
26142622
26152623 <?php if ( !empty ( $ value ['step_title ' ] ) || !empty ( $ value ['step_description ' ] ) ) { ?>
26162624
2617- <div class=" mt-how-to-step-content" >
2625+ <div <?php echo $ this -> get_render_attribute_string ( ' mt-how-to-step-content ' ); ?> >
26182626
26192627 <?php if ( !empty ( $ value ['step_title ' ] ) ) { ?>
26202628 <?php if ( !empty ($ value ['step_image_link ' ]['url ' ] ) ) { ?>
@@ -2652,8 +2660,8 @@ protected function render()
26522660 );
26532661 }
26542662 ?>
2655-
2656- <div class=" mt-how-to-step-image" >
2663+
2664+ <div <?php echo $ this -> get_render_attribute_string ( ' mt-how-to-step-image ' ); ?> >
26572665 <?php if ( 'no ' !== $ settings ['step_enable_lightbox ' ] ) {
26582666 echo '<a ' . wp_kses_post ( $ this ->get_render_attribute_string ( $ link_key ) ) . '> ' ;
26592667 } ?>
0 commit comments