Hardcode a Plugin into theme

Hi im looking at hardcoding a wp plugin into a theme, the plugin is Calendar.

This is what i have done as of yet:

1) Moved files from wp-content/plugins into a folder within theme folder and made the changes so that paths are followed correctly.

2) Set to populate database via an SQL query rather than via plugin activation

3) Altered role caps so that contributers can add / delete bookings etc

What i am now wanting to do is remove the functionality of it having to be edited within wp-admin dashboard (even though its no longer in plugins folder it still requires editing in wp-admin, due to how the plugin sets the menus etc) and rather have post_author edit it on a created page within the theme (edit_booking.php).

Its not so simple as taking out chunks of code and adding them into edit_booking.php (only the html works), im looking for a way how to port the whole thing over and away from wp-admin, im guessing that in wp-admin there are functions called via the header/footer that need also to be ported over into my own theme functions.php does anyone have experience of doing similar and care to share a few enlightening tidbits of info on how to go about this.

Regards
Martin

2 Answers
2

My first recommendation: Don’t do it!

If the plug-in author releases an update, you can and will run into conflicts. Particularly if someone installs both the new plugin and your theme at the same time. A much safer route is to build plugin support into your theme. Make things degrade gracefully in case the plugin doesn’t exists, but don’t actually code the plugin into your theme.

If you’re still intent on hard-coding things …

Put the entire plugin in a subfolder for your theme. Then, from your theme, call activate_plugin() to turn the plugin on.

Leave a Comment