Skip to content

Fix Fatal Error in shouldEnable #144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions includes/CacheTypes/Cloudflare.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,29 @@
*/
class Cloudflare extends CacheBase implements Purgeable {

/**
* Dependency injection container.
*
* @var Container
*/
protected $container;

/**
* Cloudflare constructor.
*
* @param Container $container Dependency injection container.
*/
public function __construct( Container $container ) {
$this->container = $container;
}

/**
* Whether or not the code for this cache type should be loaded.
*
* @param Container $container Dependency injection container.
* @return bool True if the cache type should be enabled, false otherwise.
*/
public static function shouldEnable() {
public static function shouldEnable( Container $container ) {
return (bool) \get_option( 'endurance_cloudflare_enabled', false );
}

Expand Down Expand Up @@ -83,10 +100,10 @@ protected function purgeRequest( $urls = array() ) {
global $wp_version;

$queryString = http_build_query( array( 'cf' => $this->getCloudflareTier() ), '', '&' );
$host = wp_parse_url( \home_url(), PHP_URL_HOST );

$host = wp_parse_url( \home_url(), PHP_URL_HOST );
$plugin_brand = $this->getContainer()->plugin()->get( 'id' );
$plugin_version = $this->getContainer()->plugin()->version;
$plugin_brand = $this->container->plugin()->get( 'id' );
$plugin_version = $this->container->plugin()->version;

$headerName = 'X-' . strtoupper( $plugin_brand ) . '-PLUGIN-PURGE';

Expand Down
Loading