Hi, I made an admin plugin storing some key/word options. The code is using it for a file modify & transfer from one server to another. Globally it works correctly, transferring with rsync and modifying with sed. (I thing I will push it to GIT if anyone is interested)
But I still have a problem that seems to be a contextual variable used and I don’t understand how to bypass it.
When performing the action, the plugin
1 gets back the option (working)
$keywords = $this->pluginConfig->get('plugins.pagetransfer.avantapres') ?? [];
2 looping in
foreach ($keywords as $pair) {
3 at this step I need to replace caracters in (“/” must be “/”) so I tried with
$escapedKey=str_replace('/', '\\/', $pair['key']);
(also tryed with reg_replace, preg_replace…)
The result is no result ! Nothing changes. if $pair[‘key’] is equal to “http://www.google.com”, $escapedKey is equal the same without any change.
After turning crazy, I tryed
$escapedKey=str_replace('/', '\\/', http://www.google.com);
and the result is good => http:\/\/www.google.com
Then as I think it may be contextual to all Grav layers, how can I overcome this behavior ?