Skip to content

Instantly share code, notes, and snippets.

@bainternet
Forked from ryanlabelle/Elementor Add Control to Existing Widget
Last active February 12, 2019 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bainternet/0e02214f83140e43a28c2b6e31a60b75 to your computer and use it in GitHub Desktop.
Save bainternet/0e02214f83140e43a28c2b6e31a60b75 to your computer and use it in GitHub Desktop.
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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment