<?php

if ( ! function_exists( 'ginevra_core_add_custom_font_widget' ) ) {
	/**
	 * Function that add widget into widgets list for registration
	 *
	 * @param array $widgets
	 *
	 * @return array
	 */
	function ginevra_core_add_custom_font_widget( $widgets ) {
		$widgets[] = 'GinevraCore_Custom_Font_Widget';

		return $widgets;
	}

	add_filter( 'ginevra_core_filter_register_widgets', 'ginevra_core_add_custom_font_widget' );
}

if ( class_exists( 'QodeFrameworkWidget' ) ) {
	class GinevraCore_Custom_Font_Widget extends QodeFrameworkWidget {

		public function map_widget() {
			$widget_mapped = $this->import_shortcode_options(
				array(
					'shortcode_base' => 'ginevra_core_custom_font',
				)
			);
			if ( $widget_mapped ) {
				$this->set_base( 'ginevra_core_custom_font' );
				$this->set_name( esc_html__( 'Ginevra Custom Font', 'ginevra-core' ) );
				$this->set_description( esc_html__( 'Add a custom font element into widget areas', 'ginevra-core' ) );
			}
		}

		public function render( $atts ) {
			echo GinevraCore_Custom_Font_Shortcode::call_shortcode( $atts ); // XSS OK
		}
	}
}
