Community Forums › Forums › Archived Forums › General Discussion › Making a plugin
Tagged: create a plugin, plugins
- This topic has 4 replies, 2 voices, and was last updated 11 years, 2 months ago by Anita.
-
AuthorPosts
-
February 11, 2013 at 11:09 am #19630AnitaKeymaster
I saw on here on somewhere, where it said to "add this you the bottom of your functions.php file or create a plugin." I cannot find this now, but... how do you take a code like that and create a plugin? Sometimes, I get three difference chunks of code to add to the functions... but if there was a way to create this plugin they referred to, I'd love to do that - learn how to do something new. I learn from SP and the people on here. It's like going to school.
Love coffee, chocolate and my Bella!
February 11, 2013 at 2:44 pm #19681Bill MurrayMemberHere's a link to a simple plugin we created for a user: http://wpp.im/d9
For a simple solution:
1) Change the plugin name to the name you want
2) Change the author, author website, version, license as you see fit
3) Put it either in the wp-content/plugins folder or a sub-folder of that folder
4) Change the code as you see fit
5) Refresh your plugin list and activate/deactivate
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
February 11, 2013 at 2:49 pm #19684AnitaKeymasterWow, that's great Bill!!! Thank you so much. Let me ask this.. I see different things in there. So, I can add different things in the one plugin or do I need to create one plugin for each function. For example, if I wanted to use the snippet to unregister a couple template layouts - I'd create one for that. And if I wanted to say, reverse the navigation - I'd create one and add that code to that? Or add everything into one plugin?
Love coffee, chocolate and my Bella!
February 11, 2013 at 3:20 pm #19691Bill MurrayMemberYou can put whatever you want in 1 plugin provided that you keep in mind the entire plugin code is run. If you want to always unregister some layouts and always reverse the navigation, you could create a plugin called "Anita's Favorite Setup" and have it do both. Certainly, you get some control with conditional tags, so if you only wanted to reverse the navigation if a certain Genesis child theme were active, you could put that code in an appropriate conditional tag. In other words, once activated, the plugin code is always run, so unless you control the impact with conditional tags, it will execute.
A further note...the plugins folder supports searching in sub-folders, so my instruction above on the ability to use a sub-folder applies to the plugins folder. The mu-plugins folder in a multisite install does NOT support subfolders, so that comment doesn't apply.
Plugins execute BEFORE the code in functions.php, so you can run into situations where your plugin does something but a child theme setup undoes it, leading you to incorrectly conclude you had the wrong plugin code. In these cases, you have to create a function that contains your commands (such as a remove action) and add that function to a hook (such as init) that comes AFTER functions.php is processed. That may sound like gibberish now, but if you ever find that code you think should work isn't behaving as you'd expect when put into a plugin, check the child theme's funcitons.php and revisit this paragraph.
If you do a google search on "wordpress custom functionality plugin" you'll find many links on the topic.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
February 11, 2013 at 3:45 pm #19699AnitaKeymasterThanks again. This is my homework for the evening. Gonna go take the dog out, make some supper and then onto PLUGINS!!!
Love coffee, chocolate and my Bella!
-
AuthorPosts
- The topic ‘Making a plugin’ is closed to new replies.