admin管理员组

文章数量:1435090

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

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

Share Improve this question edited Mar 28, 2019 at 12:54 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Mar 28, 2019 at 12:23 hardikhardik 1251 silver badge6 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 7

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).

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;
}

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”.

本文标签: How to disable updates in WordPress theme