Skip to content

Commit

Permalink
Merge branch 'release/3.5.30'
Browse files Browse the repository at this point in the history
  • Loading branch information
andykillen committed Mar 13, 2024
2 parents df25b74 + eceb372 commit fe63251
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ If you want to build a local production-ready version of the plugin you can run

## Changelog

#### 3.5.30
* When on Servebolt the plugin now checks the environement.json file to see if the key `api_url` exists. If its there it will use that, if not it will continue to use the pre-defined url for communication with the Servebolt API.

#### 3.5.29
* adapted cache tags prefix to be unique: Chosing between the shortest of bolt_id plus environment_id as one string, the domain name without dots as the other string.

Expand Down
3 changes: 3 additions & 0 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ If you're a Servebolt client, please reach out to our Support Team and we'll be

== Changelog ==

= 3.5.30 =
* When on Servebolt the plugin now checks the environement.json file to see if the key `api_url` exists. If its there it will use that, if not it will continue to use the pre-defined url for communication with the Servebolt API.

= 3.5.29 =
* adapted cache tags prefix to be unique: Chosing between the shortest of bolt_id plus environment_id as one string, the domain name without dots as the other string.

Expand Down
2 changes: 1 addition & 1 deletion servebolt-optimizer.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
Plugin Name: Servebolt Optimizer
Version: 3.5.29
Version: 3.5.30
Author: Servebolt
Author URI: https://servebolt.com
Description: A plugin that implements Servebolt Security & Performance best practises for WordPress.
Expand Down
15 changes: 14 additions & 1 deletion src/Servebolt/Helpers/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,20 @@ function getSiteId(): ?string
*
* @return mixed|null
*/
function getApiUrlFromEnvFile(): ?string
{
$env = \Servebolt\Optimizer\Utils\EnvFile\Reader::getInstance();
if ($env->api_url) {
return $env->api_url . '/v1/';
}
return "https://api.servebolt.io/v1/";
}

/**
* Get site API url from Env-file.
*
* @return mixed|null
*/
function getSiteIdFromEnvFile(): ?string
{
$env = \Servebolt\Optimizer\Utils\EnvFile\Reader::getInstance();
Expand All @@ -364,7 +378,6 @@ function getSiteIdFromEnvFile(): ?string
}
return null;
}

/**
* Get site ID from the webroot folder path.
*
Expand Down
9 changes: 8 additions & 1 deletion src/Servebolt/ServeboltOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use function Servebolt\Optimizer\Helpers\isHostedAtServebolt;
use function Servebolt\Optimizer\Helpers\isTesting;
use function Servebolt\Optimizer\Helpers\envFileFailureHandling;
use function Servebolt\Optimizer\Helpers\getApiUrlFromEnvFile;

/**
* Class ServeboltOptimizer
Expand All @@ -46,7 +47,7 @@ class ServeboltOptimizer
* Boot the plugin.
*/
public static function boot()
{
{
// Handle activation/deactivation
new PluginActiveStateHandling;

Expand All @@ -70,6 +71,7 @@ public static function boot()
WpMenuOptimizer::init();

if (isHostedAtServebolt()) {

// ACD Init
AcceleratedDomains::init();

Expand All @@ -79,6 +81,11 @@ public static function boot()
// Init environment file reader
EnvFileReader::getInstance();

// Now settings the API URI based on the environment file->api_url.
// it always defaults to the Prod api if the environment file value is not present.
if(!defined('SERVEBOLT_SDK_BASE_URI')) {
define('SERVEBOLT_SDK_BASE_URI', getApiUrlFromEnvFile());
}
}

new AddCacheTagsHeaders;
Expand Down

0 comments on commit fe63251

Please sign in to comment.