Title: Between Plugins
Last modified: May 28, 2021

---

# Between Plugins

 *  Resolved [loopforever](https://wordpress.org/support/users/loopforever/)
 * (@loopforever)
 * [5 years ago](https://wordpress.org/support/topic/between-plugins/)
 * Hello,
    I’m new to plugin development. I have a question on my mind. I would 
   be glad if you could help. I searched for the answer but couldn’t find anything
   clear. For example, there is a plugin called a. I want to make some changes in
   this plugin. For example, I want to make changes to a file at the following file
   path. plugins / a / include / x.php This file contains a code like this:
 *     ```
       function example () {
       $ value = 1;
       }
       ```
   
 * As you can imagine, if I make a change in this file (for example, the function
   in this file), it will be deleted with the update.
 * I want to code a plugin named b to solve this problem. With this plugin, I want
   to interfere with the function as in the example above. For example, the new 
   function should look like this:
 *     ```
       function example () {
       $value = 2;
       $another_value = 5;
       }
       ```
   
 * The question starts here: “Function at the beginning” does not contain an action
   or a filter as you can see. It is also not in the template file. In such a situation
   is there any way to be able to make changes with another plugin (eg b)?
    In short,
   in order to make changes to another plug-in file (or a function in it) with a
   plug-in, it should be included in the template file or should it contain an action
   or hook ? Otherwise, is it possible to edit? I hope I could explain. Thank you.
    -  This topic was modified 5 years ago by [loopforever](https://wordpress.org/support/users/loopforever/).
    -  This topic was modified 5 years ago by [loopforever](https://wordpress.org/support/users/loopforever/).

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

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years ago](https://wordpress.org/support/topic/between-plugins/#post-14495538)
 * Since it’s PHP, it depends on how it is written. PHP function names have a global
   scope, so you can’t use the same name as another function or you will get a fatal
   error. This is helped a little by what WP calls pluggable functions. That means
   that the function is wrapped in an if statement checking whether it is already
   defined.
    If the plugin you want to change didn’t do that, you need it to have
   a call to an action or filter to affect it. The only other case is if it’s a 
   class which your code can extend to override that function, like WP’s Menu_Walker
   class. _I don’t see what being in a template file has to do with plugins. Even
   themes shouldn’t put functions in a template file._
 * If the function is something that more users would want to modify, suggest it
   to the author in the plugin’s support forum. Otherwise, make a fork of the plugin
   for your use and monitor the old one for updates.
 *  Thread Starter [loopforever](https://wordpress.org/support/users/loopforever/)
 * (@loopforever)
 * [5 years ago](https://wordpress.org/support/topic/between-plugins/#post-14498532)
 * Thank you very much for your reply.
    I guess you got me wrong or I got you wrong.
   The plugin I want to make changes to can be any plugin. My question is to highlight
   a point I don’t understand.
 * Actually, what I want to ask is this: As you normally know, if a change is made
   to any plugin, it will be deleted by the update. However, if the file to be modified
   is a template file, this can be modified with the child theme. Thus, it is not
   deleted by update. I know wrong ?
 * A second alternative is hooks. For example, if filters are added to the $value(
   above) variable for a definition like above in any plugin, this can be changed
   later in the function.php file (child-theme). I know wrong ?
 * The problem is that the function I want to change this way does not meet these
   requirements. You can also think of it as a file. For example, I want to replace
   the following file in plugin A: plugins/a/ include/x.php
    Can I redefine this
   file in another plug-in to do this, ie not save the change with updates? This
   is what I want to ask.
 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years ago](https://wordpress.org/support/topic/between-plugins/#post-14498705)
 * >  if a change is made to any plugin, it will be deleted by the update.
 *  Yes, the plugin’s folder is deleted and the new one is extracted from the zip
   file.
 * > if the file to be modified is a template file, this can be modified with the
   > child theme. Thus, it is not deleted by update.
 * If the child theme is in the WP repository and has an update, any local changes
   would be deleted with the update. But if you make your own child theme, there
   are no updates from the repository to cause deletion. However, themes are loaded
   after plugins, so can’t always do the same things plugins can do. And template
   files are only loaded in certain conditions so they don’t contain functions.
 * >  if filters are added to the $value (above) variable for a definition like 
   > above in any plugin, this can be changed later in the function.php file (child-
   > theme).
 * **If** the author wrote the code with a filter, you can add code (usually with
   a plugin) to add a filter function to modify the value. But if there is no hook,
   there isn’t a good way for you to modify it. (See previous answer)
 * > Can I redefine this file in another plug-in to do this, ie not save the change
   > with updates?
 * Trying to replace the entire file is difficult also. If the plugin uses a filtered
   function like `plugins_url` in order to load that file, you could filter it to
   use your file instead, BUT the code would have to be in a plugin since plugins
   load first and there is no ordering of which plugin loads first, so it is not
   reliable. If there is no filter, there’s no good way to do it.
    As I said, a 
   change should be suggested to the author first, and if that doesn’t happen, fork
   the plugin and make your own version, while keeping up with updates to the original.
 *  Thread Starter [loopforever](https://wordpress.org/support/users/loopforever/)
 * (@loopforever)
 * [5 years ago](https://wordpress.org/support/topic/between-plugins/#post-14502929)
 * Okay dear Joy.
    You really helped a lot. Thank you so much.

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

The topic ‘Between Plugins’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [loopforever](https://wordpress.org/support/users/loopforever/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/between-plugins/#post-14502929)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
