2

I am working on a WordPress website. Earlier before me, there was one another guy has worked on that website.

Now he has done all his changes in parent theme without creating a child theme. Now, what should I do to prevent updating theme?

Also, I know it is nearly impossible but If anybody can suggest me any step to separate both changes. that would be more helpfull.

Theme is twentyseventeen

6

First of all, it is a very bad idea to modify the original theme without creating a child theme. Disabling updates of such theme is even worse idea, because without updates, your site may get infected or attacked.

So the long-term solution would be to:

  1. Check the version of modified theme.
  2. Download that version from official repository.
  3. Compare the original files with modified ones.
  4. Create a child theme containing only necessary modifications.

If you need to disable the updates for a few days, there is an easy way to do it - just change the version of your theme to 9.9.9 - WordPress will think that it is newer than the one in repository and it won't get updated. (BUT... Don't think of this hack as a solution - it's just a dirty temporary fix and you still should perform the process from points above).

2

I would agree with what Krzysiek already said - you should first be using a child theme (which is incredibly simple to set up, so there's zero reason not to do this as a best practice) and that avoiding theme updates is a recipe for eventual disaster (that goes for plugins and core, too).

That being said, while changing the version number to a ridiculously high value is a workable and very simple solution, it doesn't really avoid updates if the developer actually releases something above that version - or if they change their version numbering to something non-standard.

Here's an alternative method that handles it via the update transient. The first example would just disable all theme updates (assuming you don't have other themes installed that you DO want to allow updates for):

add_filter( 'site_transient_update_themes', 'remove_update_themes' );
function remove_update_themes( $value ) {
    return null;
}

If you want to do this for just a specific theme, then you need to search the response value for your theme's slug:

add_filter( 'site_transient_update_themes', 'remove_update_themes' );
function remove_update_themes( $value ) {

    // Set your theme slug accordingly:
    $your_theme_slug = 'your-theme-slug';

    if ( isset( $value ) && is_object( $value ) ) {
        unset( $value->response[ $your_theme_slug ] );
    }

    return $value;
}
  • We're talking about twentyseventeen, so I don't think they will change the version numbering ;) But yes - your solution will work just fine. The only problem I have with it - base on my experience - it tends to be less temporary fix ;) – Krzysiek Dróżdż Mar 28 at 13:19
1

If the question is to prevent editing the theme (and plugins) directly through the editor. You can make the following changes through wp-config.php

  1. Open up your wp-config.php file in a text editor.
  2. Anywhere above the line in that file that says

    /* That's all, stop editing! Happy blogging. */

add the line define( 'DISALLOW_FILE_EDIT', true );.

  1. Save and upload the file. Check your WordPress dashboard, you should no longer see (even on an Administrator account), the links at “Appearance > Editor” and “Plugins > Editor”.
  • ...unless the (IMHO brain-dead) developer uses FTP to update the files... Although turning off editing is a good idea, again IMHO. – Rick Hellewell Mar 28 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.