Embedder Support Forum

92 Comments in 29 Topics
Embedder Plugin Support Forum » Modify for use in a theme
Author Topic: Modify for use in a theme 4 comments / 5190 views
John

Would it be possible to move from a plugin to a theme (ofcourse, cause we can hack the shit out of wordpress). And if so how can I do that?

thanks

moztools

Hmm, that’s an interesting question. As you imply, the answer is always going to be “Yes” but there is also a big “but” to go along with it, of course.

What you are really asking for (I think) is a way for a theme to be able to identify a plugin as a prerequisite and then get WordPress to install it automatically when the theme is installed. I had a quick look around to see if anyone has done this type of thing in a theme, but could not find anything.

There is nothing to stop you from copying the Embedder code and modifying to work in a specific theme (abiding by the licensing rules, of course), but you would have to make quite a lot of changes to the code to make it work as part of a theme and not a plugin, and you would have to update your theme code every time a new version of Embedder was published, if you wanted to keep up with the latest and greatest functionality. So I would advise against this approach.

Therefore I would suggest you look at doing one of following instead:

  1. Make the plugin an optional extra to your theme — tell users that if they installed the Embedder plugin, they would get some extra flexibility or functionality with the theme (and provide them with the link to the plugin’s install page).
  2. Tell users that your theme requires the Embedder plugin to be installed, and if they install the theme without installing the plugin first, pop up a warning message telling them they need to install the Embedder plugin as well.
  3. Include a copy of Embedder in your theme’s files, and when the theme is installed, if the user does not already have Embedder installed, copy the Embedder files into the plugin directory and activate the plugin for them. Then, when a new plugin version comes out, the user will be able to upgrade Embedder like a normal plugin. (You might also want to update your theme’s package with the latest Embedder plugin version, but even if you don’t users will see that an upgrade is available when they next go to the Plugins page.

    There is a risk that the plugin directory will not be writable, and you would have to popup some instructions to the user to fix that problem, but I suspect that would not happen very often.

  4. Finally, this would probably be the best way, but also the most work to figure out. When your theme is installed, call the appropriate WordPress APIs to automatically install the Embedder plugin for the user. I don’t know how you would do that exactly, but I am sure the answer is in the WP code somewhere (in the wp-admin/includes/plugins-install.php file probably). This would ensure that the users would always have the latest and greatest version of Embedder.

The first two methods would just require you to detect whether or not the Embedder plugin is installed, which should not be more than a few lines of code, the other two would require quite a lot more code, and you would have to deal with error situations, like the plugin directory not being writable, but it would obviously make the install process easier for users.

So, your question is an interesting question, but I’m afraid that I can’t really do that much to help you since Embedder really is designed as a plugin and it would be too much work for me to get it running as part of a theme instead. In any case, I think your best bet is either to tell users to install Embedder (if you provide the link, it would be no more than two or three extra clicks for users to do it) or perhaps install the Embedder plugin for them if you feel like a bit of hacking!

What I can do, perhaps, is provide a couple of functions that would allow your theme to do things like add, query, and remove embeds, so if the plugin is installed, it can be automatically configured by your theme with a set of embeds that can then be used by the theme. So, for example, you could import a set of embeds into a separate group called something like “XYZ Theme Embeds — Do Not Change!”. Would that be useful?

John

I was afraid of that. But for now I’m very pleased with the embedder, it allows me to address the right css through tinymce. The result is that someone is able to modify a page in the right make up. It doesn’t look good in the wysiwyg editor but the end result is good. It has everything to do with nested div’s and using them.
blok2 w, x
sluit
[blok2 w=”inset” x=”titelt”]Lorum Ipsum[sluit]Blabla[sluit]

when you use the correct class name from your stylesheet it works. The embedd doesn’t get stripped by the editor, would you use <div in the editor all sort of things happen. Being a wysiswyg editor with trouble you can't see it live and the embedd itself does show.

Anyway after trying a few editors with a dozen of hacks and so, I have to say that your plugin is by far! the best solution. Perhaps there is away around, insert the embed but hide the text in the editor. Or to render the embed in the editor, so that you can see what is happening and keep the generated page working as the editor will do it's own thing adding and stripping and that sort of thing.
Does this make any sense?

Well I just started with the embedder and it's fun. If you got any ideas on the tinymce editor thing let me know…

thanks

moztools

Hey John, I understand exactly what you are talking about. I get frustrated with TinyMCE too — I even wrote a small plugin a couple of years ago that prevented WordPress from stripping out some of the spaces I tried to add (they have since fixed that particular problem so the plugin is no longer useful).

But it’s probably not the editor doing the stripping — it’s the WordPress formatting code — wpautop() and wptexturize() — that does most of that, I think. (It’s difficult to tell without specific examples). And there are at least a couple of plugins that mess around with that type of stuff (since it frustrates other people too) so you might find something that helps if you do a bit of Googling.

As for WSYWYG shortcodes in TinyMCE — that would be nice. TinyMCE does actually have plugins too, so it’s probably possible to do, but unless the other two shortcode issues are solved (adjacent shortcodes, and nested shortcodes) then embeds are always going to be fairly limited when it comes to general formatting, since if they are being used a lot, it’s too easy to get into a mess with those two problems if you’re not aware of the issues.

So I will add it to the feature-wants list — but I can’t say it’s a high priority, because of these problems, and also because it looks pretty complicated!

Regarding editors — have you tried Windows Live Writer? I’m not a big fan of MS in general, but so far Live Writer is the most consistent of the editors I have used, and I’m using the old XP version, which crashes from time to time. Apparently the 2010 and 2011 are even better if you’re using Win7.

Powered by moztools Instant Forums

Leave a Reply

Your email address will not be published. Required fields are marked *