public function getWebhook($id = null) { $webhook = new Webhook(); $webhook->setParent($this); $webhook->setService($this->getService()); if ($id) { $webhook->populate($id); } return $webhook; }
/** * */ public function RepublishFile() { //TODO Replace hardcoded string for root with dynamic stuff instead! $applicationRoot = $_SERVER['DOCUMENT_ROOT'] . '/1dv608/iwish/'; $pathToArchive = $_SERVER['DOCUMENT_ROOT'] . '/1dv608/iwish/data/physicalRepoArchive/'; $pathToFile = $pathToArchive . $this->webhook->getCommits()->getId() . '/' . $this->currentCollection . '/' . $this->file; $raw = file_get_contents($pathToFile); $datetoday = date("Ymd"); $raw .= "\n//Republished by Iwish {$datetoday}"; file_put_contents($applicationRoot . $this->file, $raw); }
/** * @return string * @throws \Exception */ public function GetContentInFile() { //TODO Replace hardcoded string for root with dynamic stuff instead! $pathToArchive = $_SERVER['DOCUMENT_ROOT'] . '/1dv608/iwish/data/physicalRepoArchive/'; $pathToFile = $pathToArchive . $this->webhook->getCommits()->getId() . '/' . $this->currentCollection . '/' . $this->file; //TODO Urrrggggh fix this later ;) $content = @file_get_contents($pathToFile); if ($content == "" || $content == null) { throw new \Exception('', 100); } return $content; }
if (version_compare(\PHP_VERSION, '5.5', '<')) { add_action('admin_notices', function () { $message = sprintf(sprintf(__('Sorry your PHP version is too old. The ThisData plugin requires PHP >= 5.5. You are running version %s.', 'thisdata-plugin'), \PHP_VERSION), Admin::getSettingsPageURL()); echo '<div class="notice notice-info"><p>' . $message . '</p></div>'; }); } else { if (is_admin()) { $admin = new Admin(); $admin->init(); $admin->render(); } add_action('init', function () { if ($apiKey = API::getKey()) { try { Events::init(API::getEventsEndpoint()); Webhook::init(); JS::init(); } catch (\Exception $e) { add_action('admin_notices', function () use($e) { $message = $e->getMessage(); echo '<div class="notice notice-error"><p>' . $message . '</p></div>'; }); } } elseif (empty($_GET['page']) || $_GET['page'] !== Admin::SETTINGS) { add_action('admin_notices', function () { $message = sprintf(__('Almost done, please enter your <a href="%s">ThisData API Key</a> to complete the installation.', 'thisdata-plugin'), Admin::getSettingsPageURL()); echo '<div class="notice notice-info"><p>' . $message . '</p></div>'; }); } }); }