1

This is a simple concept question... If I have a wordpress plugin and I want to write some functions for my own IN ADDITION to what they have already where would I put them in the wordpress file structure?

I cant put them in the original core.php files/directory because they will get wiped out when the plugins are updated right?

@NomikOS - Yeah Sure .. I have a wordpress plugin called BP-Phototag- pretty much an album..Its located in the wp-content/plugins folder. I want to add my own functions...for a specific template in my themes folder. DO i put the functions in the bpa.core.php file in the wp-conten/plugins folder or do I make a new php file that can inherit bpa.core.php functions(which I dont know how to do) and stick them in my template specific folder under wp-content/themes/mytheme folder. Im really not sure how to extend and override it...

3
  • Can you show an some example? Commented Aug 11, 2012 at 17:59
  • Tip added as EDIT 1, good luck! Commented Aug 27, 2012 at 15:36
  • Are you extending the functionality of the plugin (this is what @NomikOS showed you) OR are you hooking into the existing functionality? Many WP plugins, and even core WP, allow you to "hook" custom functionality into existing wordpress "actions". "Hooking" would be the more WP way to do this, but it depends on what the plugin creator gave you in terms of available hooks and what you want to accomplish. Commented Aug 27, 2012 at 15:41

1 Answer 1

1

If the plugin is class based, you can extend it to override/add methods. You can include the file containing your code inside plugin's directory if you want (it will not deleted after an upgrade) or directly inside plugins dir.

EDIT 1

Sorry, I didn't saw your last comment. Well, my friend, it's time to learn OOP PHP5. I recommend you PHP 5 objects, patterns, and practice. It's for PHP serious coders.

Basically you do

class leon_my_class extends BP_Phototag_class {

    function __construct()
    {
        parent::__construct();

        // my code
    }

    // overriding protected/public method 
    function BP_Phototag_method()
    {
        // this code will replace original code
    }

    // adding method
    function my_own_method()
    {

    }

}
Sign up to request clarification or add additional context in comments.

1 Comment

Beautiful..Very clear when you have the gray comments..One last question.If i used this file I have to include the original right? Is that just an include at the top?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.