public function githubHook($route)
 {
     $github = new Github();
     $http = herbert('http');
     $fd = get_option('gitcontent_settings');
     if ($route != $fd['route']) {
         return;
     }
     $args = ['meta_query' => [['key' => '_gitcontent_file', 'value' => '', 'compare' => '!=']]];
     $posts = get_posts($args);
     foreach ($posts as $post) {
         $file = get_post_meta($post->ID, '_gitcontent_file', true);
         $inputs = get_option('gitcontent_settings');
         $response = $github->checkFile($inputs, $file);
         $markdownFile = Helper::storagePath($post->ID);
         if ($response === false) {
             return;
         }
         if ($github->downloadFile($inputs, $response, $markdownFile) === false) {
             return;
         }
         wp_update_post(['ID' => $post->ID, 'post_content' => (new ParsedownExtra())->text(file_get_contents($markdownFile))], false);
     }
     echo 'Done';
 }
<?php

use GitContent\Helper;
/** @var  \Herbert\Framework\Application $container */
/** @var  \Herbert\Framework\Http $http */
/** @var  \Herbert\Framework\Router $router */
/** @var  \Herbert\Framework\Enqueue $enqueue */
/** @var  \Herbert\Framework\Panel $panel */
/** @var  \Herbert\Framework\Shortcode $shortcode */
/** @var  \Herbert\Framework\Widget $widget */
$storage = Helper::storagePath();
if (!file_exists($storage)) {
    mkdir($storage, 0755, true);
}
 /**
  * Handles the save of metabox values.
  *
  * @param $postID
  *
  * @return mixed
  */
 public function save($postID)
 {
     $validator = new Validator();
     $github = new Github();
     $http = herbert('http');
     if (!$validator->validateSave($this->nonce, $this->name, $postID)) {
         return $postID;
     }
     $file = trim($http->get('gitcontent_file'));
     if (strlen($file) == 0) {
         Notifier::success('Git Content: Disabled', true);
         update_post_meta($postID, $this->metaKey, '');
         return;
     }
     $inputs = get_option((new AdminController())->optionName);
     $response = $github->checkFile($inputs, $file);
     $markdownFile = Helper::storagePath($postID);
     if ($response === false) {
         Notifier::error('Git Content: Something went wrong, check the name of your file.', true);
         return;
     }
     if ($github->downloadFile($inputs, $response, $markdownFile) === false) {
         Notifier::error('Git Content: Something went wrong, couldn\'t download file', true);
         return;
     }
     /**
      * Should really be using wp_insert_post_data filter
      * but it fires to early, requires double update.
      * Will update later. See app/filters.php
      **/
     remove_action('save_post', [$this, 'save']);
     wp_update_post(['ID' => $postID, 'post_content' => (new ParsedownExtra())->text(file_get_contents($markdownFile))], false);
     add_action('save_post', [$this, 'save']);
     /**
      * End
      **/
     Notifier::success('Git Content: Success using ' . $file, true);
     update_post_meta($postID, $this->metaKey, $file);
 }