Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Can this plugin be converted into theme functions? WordPress

  • SOLVED

There's a particular plugin I'd like to have as a <strong>part of a core theme</strong> (instead of a plugin). The logic behind this being it will save the theme user 1 plugin upload and 1 plugin activation. Also, <strong>the theme does not function without the plugin</strong>, so it seems to make sense to have it a part of the theme itself (if possible).

Though I'm not certain if it will work in this format, and/or how viable it is. I tested it myself (as theme files and no plugin) and it mostly worked, with just a single error displaying in wp-admin. Though that single error prevented the plugin from performing it's sole-purpose (of importing Tweets into posts). It might be the format of the file inclusion calls in the plugin, though I'm not really sure.

The plugin includes cron job settings, an options page and uninstall options. It is only 8 files, and 2 of those (screenshot & readme) are not necessary if it's incorporated into a theme ...

<strong>PluginFolder</strong>
-- plugin.php
-- readme.txt
-- screenshot.png
-- uninstall.php
-- <strong>inc-folder</strong>
-------- import.php
-------- options-page.php
-------- settings.php
-------- template-tags.php


<strong>The plugin is attached to this question</strong>.

Answers (2)

2012-09-25

Kailey Lampert answers:

Should be able to just drop the plugin folder in the theme, and include include_once( get_stylesheet_directory() . '/ozh-tweet-archiver/ozh-ta.php'); in the functions.php file.

Still looking at the plugin code to see if there's anything else that needs to be tweaked, but so far no errors in my test.


TheLoneCuber comments:

I'll give it another go while you're testing Kailey. Thanks.

Is it a bad idea to incorporate this (instead of stand-alone plugin)?


Kailey Lampert comments:

Normally I wouldn't recommend it, since you'll lose the ability to update the plugin - but since this particular plugin hasn't been updated in a few years, you might be safe there.

Also depends on how integrated the plugin functionality is with the theme. If only a part of the theme were dependent on the plugin, then the plugin should definitely be optional.

As for the plugin, there are only a couple of pieces that are 'extra' once the code is integrated into the theme. There are a couple hooks on lines 65, 66 of ozh-ta.php (and their callback functions on lines 69-88)

As part of the theme they are unnecessary, but harmless. Didn't find anything that would need to be changed in the plugin to work in the theme.


Kailey Lampert comments:

I'd be tempted to leave the plugin code intact so that if there is an update, you can more easily see what's new in case something does need to be modified. That's just a personal preference though.

2012-09-25

Arnav Joy answers:

place this folder inside your theme

ozh-tweet-archiver


in functions.php write following

require_once (get_template_directory() . '/ozh-tweet-archiver/ozh-ta.php' );

and remove following lines from ozh-ta.php

/*
Plugin Name: Ozh' Tweet Archiver
Plugin URI: http://planetozh.com/blog/my-projects/ozh-tweet-archiver-backup-twitter-with-wordpress/
Description: Archive your tweets and import them as posts. Can convert #hashtags to WordPress tags.
Version: 1.0.1
Author: Ozh
Author URI: http://ozh.org/
*/

/* History
1.0 initial release
1.0.1 fix notice when no tweet found
*/

test it and let me know if there is any issue.