• Hello,

    I have been modifying a WordPress plugin to extend the functionality.There are hooks in most of the files in the plugin which I can add small bits of functionality fine. However, is it possible to go further and add actual functions to the end of files in the plugin. (Rather than functions that already exist) At the moment when the plugin author brings out an update I must re-add my code every time which gets a bit annoying after doing it a few times.

Viewing 3 replies - 1 through 3 (of 3 total)
  • What is your actual question? How to prevent a plugin that you have modified from being overwritten when an updated version is released?

    Thread Starter lch503

    (@lch503)

    No, I understand all the files are overwritten in the update process, but obviously then what I have changed is also overwritten.
    I was wondering if there is a filter / hook procedure for adding whole functions to a file, rather than just adding a few lines of code here and there in functions that already exist (like I do in the filter / hook process).
    Can this be done by maybe making my own plugin instead? Like having an add-in to the plugin?

    No, I understand all the files are overwritten in the update process, but obviously then what I have changed is also overwritten.

    You can have the cake, or you can eat it, but both is a little more complicated.

    The original plugin author obviously isn’t going to stop releasing updates, so two options that come to mind right away are:

    A) Properly rename the plugin. That prevents your changes from being overwritten, however also it prevents automatic updates to features you didn’t change.

    B) Add a filter to the plugin functions file to prevent update checks for that specific plugin only. Possible Example:

    add_filter('site_transient_update_plugins', 'remove_update_nag');
    function remove_update_nag($value) {
     unset($value->response['plugin_name/plugin_file_name.php']);
     return $value;
    }

    Same ends, different means… but again, the downside is that you receive no updates to the plugin features that you have not modified.

    The only other solution I can think of at the moment, is to take all of your own modifications and place them in a text file and store them locally for future reference. Then each time after the plugin updates, a “copy & paste” of your own functions to the updated file seems like a minimal effort solution.

    Something else to consider might be whether or not the functionality you need/added would work from the functions.php file in your active theme, rather than in the plugin. I guess that might be a possibility as well, depending on the plugin.

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

The topic ‘Adding functionality to plugin’ is closed to new replies.