<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

use Elementor\Plugin;
use Elementor\Controls_Manager;

function sifency_addons_get_elementor_templates() {
    $options = [];

    if ( class_exists( '\Elementor\Plugin' ) ) {
        $templates = Plugin::$instance->templates_manager->get_source( 'local' )->get_items();

        if ( empty( $templates ) ) {
            $options['0'] = __( 'No templates found. Please create one.', 'sifency-addons' );
        } else {
            foreach ( $templates as $template ) {
                $options[ $template['template_id'] ] = $template['title'] . ' (' . $template['type'] . ')';
            }
        }
    }

    return $options;
}