1

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

5

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.

5

This is probably not what you want to hear, but from quick look over code this plugin doesn't use a single WP practice for forms, JS and security. It doesn't let WP APIs handle data, it doesn't sanitize inputs, it doesn't escape output...

I strongly advise you to not use this code without major rewrite of forms it would take to have, at the very least, proper security aspects in place.

1
  • I actually see where your coming from with your adivise, basically the plans are to strip it right down and use it inside the theme, sanitizing/escaping will be done before it is put in a live scenario (its probably not in now as it is an admin only plugin, not to say junior admins with a grudge wouldnt abuse this security lapse), im just struggling finding something what does what this one does.
    – MartinJJ
    Commented Apr 1, 2011 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.