329 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 100+ items on Envato Market
+2 more
PaulWinslow says

Hi all,

I’ve been checking out some nice looking plugins over on CodeCanyon to implement into future themes, and I was hoping to start this thread to learn more about the possibilites of converting a plugin into a built-in function.

Is it as easy as calling the plugin from my functions file?

In a nutshell, I’ve been practising writing custom widgets (twitter feeds, etc.) and shortcodes (jquery tabs, etc.) but I’m still running into issues trying to serve this stuff with my themes.. so for now at least I’d like to bundle some quality plugins into my upcoming themes and get them released sooner rather than later.

My first question would be.. when people are writing their own plugins, how universal is the process? Are they always using the plugin API – so the code structure for each is similar.. I guess to refine my question further – if I was able to convert one plugin to my functions file, would I be able to do so for any other plugin I find as well? Or are people writing plugins in all kinds of different ways?

What I’m really looking to implement is a set of custom widgets (twitter feed, flickr, etc), a more extensive set of shortcodes, and a more extensive slider manager.

These are the ones I was checking out today..

DDSlider – http://codecanyon.net/item/ddsliderwp-11-transitions-slide-manager-panel/109211

lawley’s styles with shortcodes – http://codecanyon.net/item/styles-with-shortcodes-for-wordpress/142221

Sitebase’s widget bundle – http://codecanyon.net/item/wordpress-widget-bundle/150151

My main issue when I’ve tried writing my own widgets/shortcodes that require JS is having to stuff my </ head> section with loads of jQuery initiation stuff, whereas I’ve noticed some great themes implementing lots of custom features without calling loads of jQuery functions.

Any help at all on the subject is appreciated.

1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says

if I was able to convert one plugin to my functions file, would I be able to do so for any other plugin I find as well? Or are people writing plugins in all kinds of different ways?

You’ll find that it’s easier when the plugin is basic, like a single file (myplugin.php). These can be dropped into functions.php very easily. When you have a folder (myplugin/myplugin.php), you’ll have to update references to dependencies, and hope that the author used a constant rather than hardcoding paths.

Have you looked into just bundling the plugin as is, and using code to copy it to the plugins folder and call activate_plugin to install it? Then the user could get updates separate from your theme updates.

329 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 100+ items on Envato Market
+2 more
PaulWinslow says

Have you looked into just bundling the plugin as is, and using code to copy it to the plugins folder and call activate_plugin to install it? Then the user could get updates separate from your theme updates.

This sounds interesting. Is there anywhere I could read further into it, or any old threads covering it?

Cheers :)

1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says

Hmm…there is surprisingly little information about activate_plugin. Here is some information on the wordpress function activate_plugin: http://hitchhackerguide.com/2011/02/11/activate_plugin/

It should just be a matter of copying the file(s) to the plugin directory and calling that function.

I only know about it because I had a plugin once that had the option to install two related plugins. It used some code to unzip the two other plugins and activate_plugin to activate them. I don’t even remember what plugin it was.

329 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 100+ items on Envato Market
+2 more
PaulWinslow says

Would the user still have to download the plugin and move the files to the plugin directory, though?

1148 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+3 more
fillerspace says

You wouldn’t have to do that. Here’s what you could do:

have the plugins in a directory in your theme directory like this:

wp-content/themes/my-theme/plugins:
     /myplugin.php
     /myplugin2/ (foloder full of files)
     /myplugin3.zip

Then you add an action to the switch_theme hook that runs a function that reads all files in this directory, and if it is a file, copy it to the /plugins folder; if it is a directory, check to see if this directory exists in the plugins directory, and copy the directory over if necessary; if it is a zip file, use zip_open to open it and copy the contents to /plugins.

Then run activate_plugin on each of them.

It sounds complex, but it makes it much easier on your users, since they don’t have to download or install the plugins manually, and if the plugins are updated by their authors, you don’t have to port these changes into your code right away…users will get the standard upgrade message in the plugins options screen

1028 posts
  • Has referred 500+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
ThemeBlvd says

Hi Paul, I know this isn’t what you’re asking, but I just thought I’d share a little tidbit. I know many authors do this, but I don’t really think it’s a good idea to copy and paste plugins into your theme. With these WordPress themes, things become outdated fast as updates happen and time goes on. I know you want your buyers to not have to install plugins, but the thing is you will have a lot less head ache down the road if you don’t have all these old copies of plugins copied into your theme. You just end up with a mess of code that you did not write and it will become very confusing when you look at 5 months from now when WordPress 3.2 comes out and something isn’t compatible. It’s just a big problem I ran into in the past, and so I started just styling certain basic plugins for things like breadcrumbs, pagination, etc, and then just including a “Compatible Plugins” section in my documentation. Anything else like shortcodes, widgets, etc, are all things that I spent a lot of time coding so I know exactly how they work and what not. Just one opinion for you :-)

1246 posts LoveThemes
  • Has referred 100+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
LoveThemes says

Hi Paul, I know this isn’t what you’re asking, but I just thought I’d share a little tidbit. I know many authors do this, but I don’t really think it’s a good idea to copy and paste plugins into your theme. With these WordPress themes, things become outdated fast as updates happen and time goes on. I know you want your buyers to not have to install plugins, but the thing is you will have a lot less head ache down the road if you don’t have all these old copies of plugins copied into your theme. You just end up with a mess of code that you did not write and it will become very confusing when you look at 5 months from now when WordPress 3.2 comes out and something isn’t compatible. It’s just a big problem I ran into in the past, and so I started just styling certain basic plugins for things like breadcrumbs, pagination, etc, and then just including a “Compatible Plugins” section in my documentation. Anything else like shortcodes, widgets, etc, are all things that I spent a lot of time coding so I know exactly how they work and what not. Just one opinion for you :-)

+1

You will end up with a lot of headaches. You’d be much better trying to code additional stuff yourself so you know that you can keep it updated and compatible.

329 posts
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 100+ items on Envato Market
+2 more
PaulWinslow says

Guys, don’t worry I’m not looking to just copy and paste plugin files into my themes – my question was probably blurred when I asked fillerspace for more info above, I was just interested to read more on that. Thanks, though :)

I’m looking to extract the functionality of a plugin into my theme’s functions so that the widgets and shortcodes from the links in my first post are built into my theme internally. And possibly the functionality of a slider manager and things of that nature. I obviously realise it’d be hell to just throw plugin files into my theme – I can imagine what a nightmare that could turn into with updates and compatibility.

164 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+3 more
tonyc says

Hi,

Most of the time you won’t have any problems just placing the plugin’s files in your themes folder for example in a “functions/plugins/” folder and then including the main plugin file from your functions.php. I’ve done this several times and here are some tips:

1. Never keep a copy of the plugin in the wp-content/plugins/ folder.

Sometimes when the plugin is more complex it may include some files by calling them trough the plugin api which means that it will load the files in the wp-content/plugins/plugin-name folder. By not keeping a copy of the plugin there you would generate php errors and you can go trough the code and fix that by calling your copies of the files.

2. Check for namespacing and translation issues. Sometimes the plugins will use a different namespace than your theme.

3. Always check with the author of the plugin if he is ok to incorporate his plugin in your theme. It’s not against the law but some may not be content with it and it wouldn’t be a friendly thing to do.

4. Make sure you know the code of the plugin inside out as you will need to support it if you integrate it rather than suggesting your customers to install it themselves.

5. First buy a regular license and try to integrate the plugin and then buy the extended one as some plugins are too much of a hassle to integrate to be worth it. You better find alternatives in this case.

by
by
by
by
by
by