/**
  * Format the patch.
  * We're encoding everything here for security reasons.
  * We're also going to check the current versions of Avada & Fusion-Core,
  * and then build the hash for this patch using the files that are needed.
  */
 private static function format_patch($patch)
 {
     // Get the fusion-core plugin version
     $fusion_core_version = class_exists('FusionCore_Plugin') ? FusionCore_Plugin::VERSION : false;
     // Get the avada theme version
     $avada_version = Avada::get_theme_version();
     $patches = array();
     if (!isset($patch['patch'])) {
         return;
     }
     foreach ($patch['patch'] as $key => $args) {
         if (!isset($args['context']) || !isset($args['path']) || !isset($args['reference'])) {
             continue;
         }
         if ('avada' == $args['context'] && $avada_version == $args['version']) {
             $patches[$args['context']][$args['path']] = $args['reference'];
         } elseif ('fusion-core' == $args['context'] && $fusion_core_version == $args['version']) {
             $patches[$args['context']][$args['path']] = $args['reference'];
         }
     }
     return base64_encode(json_encode($patches));
 }