[Defender Pro] Catch potential loss of functions.php

0

You click the Update button for themes, and then remember you have customizations in functions.php. Help! Defender!…

What if Defender saves your active them functions.php every day? You update and overwrite the file. Defender offers you the original and a diff view so that you can put your changes back in.

Or, just get the daily snapshot and don’t worry about diffs and editing.

Or, don’t get daily snapshots. After a theme update, get a snapshot of functions.php. If you click to Update the theme, just before the update, defender checks to see if the current file is different from the original, and it gets a new save right there. Now, right after you wipe away the tears for your lost functions, you can get Defender to show you the before and after files, maybe with a diff, and maybe the new file, with a three-way diff … OK, that’s pushing it.

This functionality would save a site from needing to recover the one file from other backup/snapshots, which can be somewhat painful depending on how they’re done – or IF they’re done.

(No, this hasn’t happened to me yet, but anytime I or someone does an update, or there is an auto-update, I choke a bit, wondering if we put anything in functions.php just as a quick fix/test.)

  • Nebu John
    • FLS

    Hi Tony G ,

    I hope you are keeping well today, and thank you for reaching out to us.

    The idea looks good, but I am afraid this doesn’t look like a feature that can be added with Defender. The Defender offers security features to protect your WordPress sites from malicious attacks.

    Also, you can always use a mu-plugin or child theme so that you won’t lose changes on your functions.php when the theme is updated, which is the recommended workflow.

    Kind Regards,
    Nebu John

    • Jack Alltrade
      • WordPress Warrior

      A child theme runs off of the theme framework. The theme is the core functionality or blueprint, and the child theme contains the customizations.

      So, when you update the theme, it doesn’t overwrite your customizations.

      They work in much the same way as the kit cars that were popular in the 80s.

  • Tony G
    • Mr. LetsFixTheWorld

    To be clear, I/we write plugins here, and I’m entirely aware of the benefits of using plugins and child themes. This was suggested purely as a matter of convenience, and on a whim.

    As I said, sometimes I wonder if we accidentally put something of minimal value in the default theme, just for testing or to solve some little challenge. Sure, we can create a plugin. Sure, we can create a child theme.

    But how many folks here do either of those things? Especially now when block themes has created some industry confusion.
    How many other people ask “Child themes?”
    How many people here just follow the articles and put everything in functions.php of their default theme? << I suspect most. Anyone wanna raise a hand? :hand_splayed_tone2:

    Nithin is right – this isn’t a good fit for Defender. Better for Branda. I posted for Defender because I personally tend to think of potential data loss as a security issue, as in “social security” or “security blanket”, of course in addition to authentication, blocking, scanning, logging, and all of the other awesome things that Defender does. But I completely agree that this is not the purpose of Defender.

    I’ll accept that this is probably not a good fit for Branda either. That a site admin should use established workflow. But Branda is a convenience tool that facilitates (makes “easy”) a ton of things that site admins “should” or could do by other means. That’s why I suggested this. It’s just one less “gotcha” to worry about.

    I’m fine if this isn’t seen as a good fit for a product enhancement. There’s SO much else to do.

    Thanks!