• Resolved thierrybeauchemin

    (@thierrybeauchemin)


    Hi,
    I’m struggling to make an easy Replace. I would like to add an extra span around a word.It’s a staight forward replacement, no placeholder, no multiple instance, nothing like that.

    Find: myWORD
    Replace: <span class=”myClass”>myWORD</span>

    My problem is the quotation mark which screw everything and also the space between “span” and “class”. I’m trying with adding some \ in front but nothing seem to work.

    Any help would be appreciated πŸ™‚

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    That should work fine. I’m not sure what issue you’re describing. You’re NOT trying to use regex, correct?

    Thread Starter thierrybeauchemin

    (@thierrybeauchemin)

    Exactly, no regex nothing… but I beleive I found the problem.

    What happens is Space are converted to “&nbsp;” and quotation mark are being removed. I think it have to do with WordPress doing something AFTER your plugin, could it be the case ?

    https://stackoverflow.com/questions/5940854/disable-automatic-formatting-inside-wordpress-shortcodes

    Could wordpress be formating the “Replace text” after your hook ?
    If so, could I place your code AFTER the wpautop ?

    Thank for the help, really appreciated πŸ™‚

    Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    The plugin has been designed to be the last thing that runs i.e. after plugins, themes, etc. So I can’t see additional formatting being applied after my plugin. The only exception are caching plugins which are still able to cache pages modified by my plugin and deliver those cached pages.

    Have you tried building the rule in pieces? For example, replace myword with >myword< and if that works add more and more to the span tag until something stops working. It might provide a clue as to the problem.

    Thread Starter thierrybeauchemin

    (@thierrybeauchemin)

    Caching is disable right now, but good to know πŸ™‚

    Ok, I found the problem by doing 2 test:

    Test 1:search myWORD | replace potato
    myWORD present in main Content and also Footer
    Works perfectly

    Test 2: search myWORD | replace “potato” (WITH quotation)
    myWORD present in main Content and also Footer
    myWORD in Content is replace with quotation
    myWORD in the footer is MISSING (not even present in the source code).

    I’m using Elementor Pro to create the footer (I guess it inject it at some point). I strongly suspect that somehow Elementor FOOTER “retouch” your code. as it works perfectly with the main content (also created with elementor, just not injected). Not sure how to progress next…

    Thread Starter thierrybeauchemin

    (@thierrybeauchemin)

    Ok, just to inform. If I use Quotation mark in the replace field I cannot edit the page with Elementor (It’s stuck on loading with the big E).

    So I guess you something in this plugin break Elementor if quotation are used.

    Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    Thanks for letting me know. I use quotation marks in my rules all the time so perhaps there is something special with the Elementor theme.

    Thread Starter thierrybeauchemin

    (@thierrybeauchemin)

    I’ve done a bit further test, and it really point to “where” this plugin is searching:

    I’ve added a str_replace in my function.php and it works flawlessly in the $content section, but it cannot catch the footer. I’ve also found code that use $buffer (trying to catch the final HTML), but this also didn’t work (while working perfectly in the $content section).

    So it’s either a question of “Region” (not sure if it’s the right wp term)
    or Elementor is being called at the end bypassing everything…

    Hope this can help if others have the problem, thank for the support πŸ™‚
    Awesome plugin BTW

    Plugin Author Marios Alexandrou

    (@marios-alexandrou)

    Thank you for the additional information. This is the first theme that has shown this behavior. Are you using the free version of theme? If so, I’ll have to try it out.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Replace with HTML’ is closed to new replies.