bainternet
12/7/2017 - 12:28 PM

Elementor Add Control to Existing Widget

<?php
/* Add Image Stretch Option Control to the Image Gallery Widget */
add_action( 'elementor/element/before_section_end', function( $element, $section_id, $args ) {
    /** @var \Elementor\Element_Base $element */
    if ( 'image-gallery' === $element->get_name() && 'section_gallery' === $section_id ) {

        $element->add_control(
            'image_stretch',
            [
                'label' => __( 'Image Stretch', 'elementor' ),
                'type' => \Elementor\Controls_Manager::SELECT,
                'default' => 'no',
                'options' => [
                    'no' => __( 'No', 'elementor' ),
                    'yes' => __( 'Yes', 'elementor' ),
                ],
            ]
        );
    }
}, 10, 3 );