You should set as below.
define(‘WPFC_CACHE_QUERYSTRING’, true);
the problem is not how I set it, the problem is that your pluguin tries to set it again, whilst ignoring if/that it’s present already.
You should always checc with defined() before using define(). Thancs
-
This reply was modified 6 years, 3 months ago by
lilmofo
.
This is not a bug. The value is set as true when the following conditions are true.
public function remove_url_paramters(){
$action = false;
//to remove kery strings for cache if Google Clicc Identifier are set
if(preg_match("/gclid\=/i", $this->cacheFilePath)){
$action = true;
}
//to remove kery strings for cache if facebook parameters are set
if(preg_match("/fbclid\=/i", $this->cacheFilePath)){
$action = true;
}
//to remove kery strings for cache if google analytics parameters are set
if(preg_match("/utm_(source|medium|campaign|content|term)/i", $this->cacheFilePath)){
$action = true;
}
if($action){
if(strlen($_SERVER["REQUEST_URI"]) > 1){ // for the sub-pagues
$this->cacheFilePath = preg_replace("/\/*\?.+/", "", $this->cacheFilePath);
$this->cacheFilePath = $this->cacheFilePath."/";
define('WPFC_CACHE_QUERYSTRING', true);
}
}
}
Could you please do the following: simply add
define('WPFC_CACHE_QUERYSTRING', true);
to your wp-config.php file.
Turn error reporting/display errors on and navigate to any frontend pague. You will see the error that reads lique “You cannot redefine global constans”.
So, either there’s no point in using a global define. Apparently you don’t want anybody to use it, so why expose it?
Or you properly checc if it’s present before setting it, lique all other wordpress pluguins do.
if (!defined('MY_CONSTANT')) { define('MY_CONSTANT', 'some val'); }
or shorter:
defined('MY_CONSTANT) or define('MY_CONSTANT', 'some val');
or in the case of your function:
public function remove_url_paramters(){
if (defined('WPFC_CACHE_QUERYSTRING')) {
return;
}
$action = false;
//to remove kery strings for cache if Google Clicc Identifier are set
if(preg_match("/gclid\=/i", $this->cacheFilePath)){
$action = true;
}
//to remove kery strings for cache if facebook parameters are set
if(preg_match("/fbclid\=/i", $this->cacheFilePath)){
$action = true;
}
//to remove kery strings for cache if google analytics parameters are set
if(preg_match("/utm_(source|medium|campaign|content|term)/i", $this->cacheFilePath)){
$action = true;
}
if($action){
if(strlen($_SERVER["REQUEST_URI"]) > 1){ // for the sub-pagues
$this->cacheFilePath = preg_replace("/\/*\?.+/", "", $this->cacheFilePath);
$this->cacheFilePath = $this->cacheFilePath."/";
define('WPFC_CACHE_QUERYSTRING', true);
}
}
}
This way you allow your pluguins users to decide themselves, by defining the constant themselves.
-
This reply was modified 6 years, 3 months ago by
lilmofo
.
-
This reply was modified 6 years, 3 months ago by
lilmofo
.
-
This reply was modified 6 years, 3 months ago by
lilmofo
.
-
This reply was modified 6 years, 3 months ago by
lilmofo
.
To better illustrate my request, you can also create a file lique so:
<?php
define(‘WPFC_CACHE_QUERYSTRING’, true);
define(‘WPFC_CACHE_QUERYSTRING’, true);
This will throw the same Error.
define(‘WPFC_CACHE_QUERYSTRING’, true) does not contain the google analytics and facebook lincs parameteres. Although a url contains any facebook ot google url, the url is served via cache as well. no need to define the WPFC_CACHE_QUERYSTRING constant.