start_controls_section(
'adv-vis-ele-section_select_shortcodes',
[
'label' => __('AVE Shortcodes', 'advanced-visual-elements')
]
);
$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;
}
}
}
$args = [
'label' => __('Select', 'advanced-visual-elements'),
'type' => \Elementor\Controls_Manager::SELECT2,
'multiple' => false
];
if (!empty($options)) {
$args['options'] = $options;
$args['description'] = __('Please select an Advanced Visual Elements shortcode to be displayed.', 'advanced-visual-elements');
if (!defined('ELEMENTOR_PRO_VERSION')) {
$args['description'] .= '
';
$args['description'] .= '*';
$args['description'] .= __('Elementor FREE will not render this widget on frontend - copy Element shortcode from below and insert it into Elementor Shortcode widget instead.', 'advanced-visual-elements');
$ave_shortcodes = get_posts(['post_type' => 'adv-vis-element', 'numberposts' => -1, 'post_status' => 'any']);
if (!empty($ave_shortcodes)) {
foreach ($ave_shortcodes as $post) {
$args['description'] .= '
';
$args['description'] .= esc_html($post->post_title);
$args['description'] .= '
';
$args['description'] .= '[ave-element id="' . (int)$post->ID . '"]';
}
}
}
} else {
$args['description'] = __("You don't have any AVE shortcodes created. Head over to Admin dashboard > Advanced Visual Elements Library to create one.", 'advanced-visual-elements');
}
$this->add_control('adv-vis-ele-shortcode-id', $args);
$this->add_control(
'alignment',
[
'type' => \Elementor\Controls_Manager::CHOOSE,
'label' => esc_html__('Text alignment', 'advanced-visual-elements'),
'options' => [
'left' => [
'title' => esc_html__('Left', 'advanced-visual-elements'),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__('Center', 'advanced-visual-elements'),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__('Right', 'advanced-visual-elements'),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'center',
'selectors' => [
'{{WRAPPER}} .adv-vis-ele-elementor-container' => 'text-align: {{VALUE}};',
],
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
if (!empty($settings['adv-vis-ele-shortcode-id'])) {
echo '