Skip to content

Commit

Permalink
Merge pull request #80 from interactiv4/feature/M095M01A-18
Browse files Browse the repository at this point in the history
feature/M095M01A-18 [WORDPRESS] Implement Edge Modules functionality
  • Loading branch information
vvuksan authored Jul 30, 2020
2 parents c55a9b4 + de65460 commit 47193ad
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions src/classes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ protected function __construct()
trailingslashit('service'),
trailingslashit(purgely_get_option('fastly_service_id')),
]);

$this->get_active_version();
}

/**
Expand All @@ -47,11 +45,24 @@ protected function __construct()
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new self();
$instance = new self();
$instance->validate();
self::$instance = $instance;
}
return self::$instance;
}

protected function validate()
{
try {
$this->get_active_version();
} catch (\Exception $e) {
wp_die("<div class=\"error notice\">
<p>Unable to connect to Fastly. Please go to General settings and review your settings.</p>
</div>");
}
}

public function get_active_version()
{
if (is_null($this->active_version)) {
Expand Down Expand Up @@ -118,25 +129,6 @@ public function snippet_exists($name, $version = null)

public function upload_snippet($version, $snippet)
{
// Perform replacements vcl template replacements
// if (isset($snippet['content'])) {
// $adminUrl = $this->vcl->getAdminFrontName();
// $adminPathTimeout = $this->config->getAdminPathTimeout();
// $ignoredUrlParameters = $this->config->getIgnoredUrlParameters();
//
// if ($ignoredUrlParameters === "") {
// $queryParameters = '&';
// } else {
// $ignoredUrlParameterPieces = explode(",", $ignoredUrlParameters);
// $filterIgnoredUrlParameterPieces = array_filter(array_map('trim', $ignoredUrlParameterPieces));
// $queryParameters = implode('|', $filterIgnoredUrlParameterPieces);
// }
//
// $snippet['content'] = str_replace('####ADMIN_PATH####', $adminUrl, $snippet['content']);
// $snippet['content'] = str_replace('####ADMIN_PATH_TIMEOUT####', $adminPathTimeout, $snippet['content']);
// $snippet['content'] = str_replace('####QUERY_PARAMETERS####', $queryParameters, $snippet['content']);
// }

$url = $this->base_url . "version/{$version}/snippet";
if (!$this->snippet_exists($snippet['name'], $version)) {
$verb = Requests::POST;
Expand Down

0 comments on commit 47193ad

Please sign in to comment.