start_controls_section( 'section_shortcode', [ 'label' => __( 'Shortcode', 'awelementor' ), ] ); $this->add_control( 'shortcode', [ 'label' => __( 'Enter your shortcode', 'awelementor' ), 'type' => Controls_Manager::TEXTAREA, 'dynamic' => [ 'active' => true, ], 'placeholder' => 'gallery', 'default' => '', ] ); $this->end_controls_section(); $this->start_controls_section( 'section_args', [ 'label' => __( 'Arguments', 'awelementor' ), ] ); $repeater = new Repeater(); $repeater->add_control( 'argument', [ 'label' => __( 'Argument', 'awelementor' ), 'type' => Controls_Manager::TEXT, ] ); $repeater->add_control( 'value', [ 'label' => __( 'Value', 'awelementor' ), 'type' => Controls_Manager::TEXT, 'dynamic' => [ 'active' => true, ], ] ); $this->add_control( 'args', [ 'type' => Controls_Manager::REPEATER, 'fields' => $repeater->get_controls(), 'title_field' => '{{{ argument }}}="{{{ value }}}"', ] ); $this->end_controls_section(); } /** * Render shortcode widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 1.0.0 * @access protected */ protected function render() { $shortcode = trim($this->get_settings_for_display( 'shortcode' ), '[]'); $args = array_reduce($this->get_settings_for_display( 'args' ), function($args, $arg) { if (isset($arg['argument'], $arg['value'])) { $args .= " {$arg['argument']}=\"{$arg['value']}\""; } return $args; }); echo '