<?php
if ( ! class_exists( 'Integrate_Palace_Properties_Icons' ) ) {

class Integrate_Palace_Properties_Icons {

	private static $ipp_svgs = null;

	public static function fetch_svg_icon( $icon = '' ) {
		$output = '<span class="ippr-flex">';

		if ( ! self::$ipp_svgs ) {
			global $wp_filesystem;

			// Initialize WP_Filesystem
			if ( ! $wp_filesystem ) {
				require_once ABSPATH . 'wp-admin/includes/file.php';
				WP_Filesystem();
			}

			$json_file = INTEGRATE_PALACE_P_PLUGIN_DIR . 'includes/customizer/assets/svg/svg.json';
			self::$ipp_svgs = $wp_filesystem->exists( $json_file ) ? json_decode( $wp_filesystem->get_contents( $json_file ), true ) : [];
		}

		$output .= isset( self::$ipp_svgs[ $icon ] ) ? self::$ipp_svgs[ $icon ] : '';
		$output .= '</span>';

		return $output;
	}
}

}
