• SaladGoat

    (@saladgoat)


    I have done this a couple of times, but every time WordPress comes out with a new version, it overwrites my changes and I gotta do it again. I know some plugins provide an alternate locations for stylesheets, so you can customize them and not be overwritten when it’s updated. Is there any way I can put a file in another folder that will always override the default wptexturize? (Actually I think it’s called formatting.php, but you know what I mean. I hope.)
    Like if I put it in my theme folder, would that work?
    Or possibly disable it in functions.php and write some sort of re-direct code in functions to point to the new file?
    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    every time WordPress comes out with a new version, it overwrites my changes and I gotta do it again.

    Every time someone edits a core file, really bad things happen. That’s just not the way to do it as that would require you to edit core files such as wp-includes/formatting.php.

    A better way would be like to use a plugin and remove the filters for wptexturize and add your modified version instead to the filter queue.

    The rule for pasted code is for more that 10 lines use pastebin.com, so instead of pasting here I’ll follow that rule. ??

    Take a look at this code. https://pastebin.com/3VgkRBqT

    You will need to put your function in that plugin for sg_wptexturize.

    Or a safer approach would be to leave wptexturize alone and just reverse the modifications that you personally dislike from that filter.

    For example, to convert the & #8211; (less the space) back to a double dash make another plugin that runs your filter last.

    Here’s the Pastebin for that too. https://pastebin.com/HWYGHDc7

    That new function mh_un_en_dash get added to those filters at a priority of 50 so they should end up running well after the wptexturize filter.

    Try using plugins instead and think of the kittehs. ??

    Thread Starter SaladGoat

    (@saladgoat)

    Thanks for your excellent suggestions!
    I think I like the second one – you’re right, it’s much safer.
    Is it an actual plugin? I think I saw somewhere online how to make your own plugin, so I’m sure I can figure out what to do with your code if it is. Just want to make sure this isn’t just something I add to functions.php or some other file.

    I’m always very careful when modifying core files. Make backups, read exactly what is in them and know what is going to happen before it happens. Doesn’t always work out, but so far I guess I have been lucky in being able to re-implement backups without problems.

    I always think the fewer plugins you have, the faster the page will load. Am I being paranoid about that? Does it have any real effect at all? I love the kittehs! :p

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Is it an actual plugin?

    I hope so, I tested it on my install just like that. ?? Just copy that into wp-content/plugins and activate it. If something goes wrong, just delete that file.

    I always think the fewer plugins you have, the faster the page will load.

    Generally that’s true if you are talking about lots of code that does a lot for work, data manipulation, etc. But that code is very light and doesn’t do much, so it shouldn’t have any noticeable impact on your load speed.

    Also doing it in a plugin is the same as doing it in your theme’s functions.php file. Using it in a plugin will mean that you can switch themes without that going away.

    Thread Starter SaladGoat

    (@saladgoat)

    Very cool. Too busy with other concerns right now, but will give this a whirl tomorrow.
    Thanks!

    Thread Starter SaladGoat

    (@saladgoat)

    Reporting back … the second option, which seemed easier, didn’t work for me. Not sure what I did wrong, but I copied and pasted your code and there was no change to my text. So I gave up.

    I just tried the first option – which seemed complicated at first but then I got it – and it works, so yay!

    Thanks. I will be installing my new plugin on all my WordPress sites. ??
    Want credit?

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    I just tried the first option – which seemed complicated at first but then I got it – and it works, so yay!

    Fun isn’t it? And now you can make plugins to filter/change things to your heart’s content. With that under your belt you’ll be doing some cool things now.

    Want credit?

    Thanks, but I’m sure I appropriated *cough*STOLE*COUGH!!* the idea from someone else. ??

    For example, to convert the & #8211; (less the space) back to a double dash make another plugin that runs your filter last.

    Here’s the Pastebin for that too. https://pastebin.com/HWYGHDc7

    That new function mh_un_en_dash get added to those filters at a priority of 50 so they should end up running well after the wptexturize filter.

    That’s what I’ve been looking for a while ! I was trying fill the global $wp_cockneyreplace array and merge keys.

    That pastebin has one error in it. The function should

    return $content;

    and NOT … return $text;

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘edit wptexturize’ is closed to new replies.