/**
  * Register custom icon set data in the internal sets array.
  *
  * @since 1.4.6
  * @access private
  * @return void
  */
 private static function register_custom_sets()
 {
     // Get uploaded sets.
     $enabled_icons = FLBuilderModel::get_enabled_icons();
     $upload_info = FLBuilderModel::get_cache_dir('icons');
     $folders = glob($upload_info['path'] . '*');
     // Make sure we have an array.
     if (!is_array($folders)) {
         return;
     }
     // Loop through uploaded sets.
     foreach ($folders as $folder) {
         $folder = trailingslashit($folder);
         // This is an Icomoon font.
         if (file_exists($folder . 'selection.json')) {
             $data = json_decode(file_get_contents($folder . 'selection.json'));
             $key = basename($folder);
             $url = str_ireplace($upload_info['path'], $upload_info['url'], $folder);
             if (isset($data->icons)) {
                 if (is_admin() || in_array($key, $enabled_icons)) {
                     self::$sets[$key] = array('name' => $data->metadata->name, 'prefix' => '', 'type' => 'icomoon', 'path' => $folder, 'url' => $url, 'stylesheet' => $url . 'style.css', 'icons' => array());
                     foreach ($data->icons as $icon) {
                         $prefs = $data->preferences->fontPref;
                         $postfix = isset($prefs->postfix) ? $prefs->postfix : '';
                         if (isset($prefs->selector) && 'class' == $prefs->selector) {
                             $selector = trim(str_replace('.', ' ', $prefs->classSelector)) . ' ';
                         } else {
                             $selector = '';
                         }
                         self::$sets[$key]['icons'][] = $selector . $prefs->prefix . $icon->properties->name . $postfix;
                     }
                 }
             }
         } else {
             if (file_exists($folder . 'config.json')) {
                 $data = json_decode(file_get_contents($folder . 'config.json'));
                 $key = basename($folder);
                 $name = empty($data->name) ? 'Fontello' : $data->name;
                 $url = str_ireplace($upload_info['path'], $upload_info['url'], $folder);
                 $style = empty($data->name) ? 'fontello' : $data->name;
                 // Append the date to the name?
                 if (empty($data->name)) {
                     $time = str_replace('icon-', '', $key);
                     $date_format = get_option('date_format');
                     $time_format = get_option('time_format');
                     $date = date($date_format . ' ' . $time_format);
                     $name .= ' (' . $date . ')';
                 }
                 if (isset($data->glyphs)) {
                     if (is_admin() || in_array($key, $enabled_icons)) {
                         self::$sets[$key] = array('name' => $name, 'prefix' => '', 'type' => 'fontello', 'path' => $folder, 'url' => $url, 'stylesheet' => $url . 'css/' . $style . '.css', 'icons' => array());
                         foreach ($data->glyphs as $icon) {
                             if ($data->css_use_suffix) {
                                 self::$sets[$key]['icons'][] = $icon->css . $data->css_prefix_text;
                             } else {
                                 self::$sets[$key]['icons'][] = $data->css_prefix_text . $icon->css;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
    _e('Override network settings?', 'fl-builder');
    ?>
		</label>
		<?php 
}
?>
		
		<div class="fl-settings-form-content">

			<p><?php 
printf(__('Enable or disable icon sets using the options below or upload a custom icon set from either <a%s>Icomoon</a> or <a%s>Fontello</a>.', 'fl-builder'), ' href="https://icomoon.io/" target="_blank"', ' href="http://fontello.com/" target="_blank"');
?>
</p>
			
			<?php 
$enabled_icons = FLBuilderModel::get_enabled_icons();
$icon_sets = FLBuilderIcons::get_sets_for_current_site();
foreach ($icon_sets as $key => $set) {
    $checked = in_array($key, $enabled_icons) ? ' checked' : '';
    ?>
				<p>
					<label>
						<input type="checkbox" name="fl-enabled-icons[]" value="<?php 
    echo $key;
    ?>
" <?php 
    echo $checked;
    ?>
>
						<?php 
    echo ' ' . $set['name'];