start_controls_section( 'adv-vis-ele-section_select_shortcodes', [ 'label' => __('AVE Shortcodes', 'wp-ave') ] ); $ave_shortcodes = get_posts(['post_type' => 'adv-vis-element', 'post_status' => 'any', 'numberposts' => -1]); $options = []; if (!empty($ave_shortcodes)) { foreach ($ave_shortcodes as $shortcode) { if ($shortcode->post_status !== 'publish') { $options[$shortcode->ID] = $shortcode->post_title . ' (draft)'; } else { $options[$shortcode->ID] = $shortcode->post_title; } } } $this->add_control( 'adv-vis-ele-shortcode-id', [ 'label' => __('Select', 'wp-ave'), 'description' => __('Please select an Advanced Visual Elements shortcode to be displayed', 'wp-ave'), 'type' => \Elementor\Controls_Manager::SELECT2, 'multiple' => false, 'options' => $options ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); if (!empty($settings['adv-vis-ele-shortcode-id'])) { echo do_shortcode('[ave-element id="' . (int)$settings['adv-vis-ele-shortcode-id'] . '"]'); } } } \Elementor\Plugin::instance()->widgets_manager->register(new Adv_Vis_Ele_Elementor_Shortcode()); });