Hello Daniel,
Thx for reply.
I’m not a dev but i did this function maybe you can make it better and add it on your plugin as feature > Elementor Pro integration.
// custom Custom_Avg_Tag dynamic tag
add_action( 'elementor/dynamic_tags/register_tags', function( $dynamic_tags ) {
class Elementor_Global_Colors_Tag extends \Elementor\Core\DynamicTags\Tag {
public function colors_options(){
$colors = kt_Central_Palette::instance()->get_palette();
$colors_array = array();
$color_code_array = array();
$color_name_array = array();
foreach ($colors as $color) {
$color_name = $color['name'];
$color_code = 'var(--' . str_replace(' ', '', $color_name) . ')';
$color_code_array[] = $color_code;
$color_name_array[] = $color['name'];
}
$colors_array = array_combine($color_code_array, $color_name_array);
return $colors_array;
}
public function get_name() {
return 'Elementor_Global_Colors_Tag';
}
public function get_categories() {
return [ 'color' ];
}
public function get_group() {
return [ 'site' ];
}
public function get_title() {
return 'Global Colors';
}
protected function _register_controls() {
$colors_array = $this->colors_options();
$this->add_control(
'fields',
[
'label' => __( 'Fields', 'text-domain' ),
'type' => \Elementor\Controls_Manager::SELECT,
'options' => $colors_array,
'default' => 'default',
]
);
}
public function render() {
$fields = $this->get_settings( 'fields' );
echo $fields;
}
}
$dynamic_tags->register_tag( 'Elementor_Global_Colors_Tag' );
} );
This add a custom Tag from the Elementor Dynamic tags who get the Palette of your plugin.
But name is a problem more with autogeneration… so maybe we need a static name by id > kt-palette-1, kt-palette-2 etc… and set the default value to kt-palette-1
Maybe you can have a look.
Thx Laurent