May 31, 2008

I have reached a point with the plugin that I am developing where I have been many times before. Most of the core functionality is done and I am deciding how to expose that to the users. Do I offer template tags or settings?

I am a big fan of the WordPress theme system and there is a good argument for suggesting that plugins should look to expand on the great work that has already been done by offering template tags wherever there is additional reader-facing content.

There are obviously some exceptions to this, there is no point creating a new tag for content that is modified in a certain way, just hook into the current tag, and plugins like the excellent Ajax Edit Comments that add content where the placement is a given (buttons below the comment text), but on the whole should we be aiming to create tags or not?

Here is the example from the plugin I am working on right now:

My plugin adds extra fields for the commenters to complete to show things such as which version of WordPress they are using. When their comment is displayed this information is displayed with the comment. I have included a test comment below just for fun.

The extra statement, that this comment relates to WordPress version x, is added with a comment tag right now, but I could just as easily provide an admin panel with the option to include it above or below the comment, and asking what separators and introductory text should be used.

So the question is this: is there a preferred method that plugin authors should aim for? Should we be avoiding admin panels when the same functionality can be produced using a template tag, as with most of the standard content, or should we be aiming for as seamless an experience as possible where no editing is necessary?

The third option, of course, is that there shouldn’t be a preferred method, but I dismiss that one. I feel there should be a target.



Wordpress feature image page?
24 comments on page 1065

Addsettingsfield?
3 comments on page 793

Shorter link?
4 comments on page 1190

Shorter link?
4 comments on page 1190

Cssimageforlogin?
no comment on page 128

Cssimageforlogin?
no comment on page 128

Get featured image url wordpress?
24 comments on page 1065

How to clear wpcache?
9 comments on page 1310

Photo gallry code html5?
6 comments on page 1305

Wordpress get image size?
24 comments on page 1065

Sitecouk wptheme?
2 comments on page 1376

Wordpress chat disqus?
no comment on page 1308

Howtocreategoodsizelayout?
4 comments on page 1026

Friend connect profile?
6 comments on page 1364

Get medium image from post?
24 comments on page 1065

Tabbed widgets wp?
no comment on page 333

Wordpress pictue cache lschen?
9 comments on page 1310

Wordpress plugin post separator?
no comment on page 1371

Display photos html 5?
6 comments on page 1305

Fun wordpress themes?
2 comments on page 1376

Wp featured image without size?
24 comments on page 1065

Wordpress get url global?
4 comments on page 1190

Wp unlimited?
3 comments on page 1141

Html5 image gallery?
6 comments on page 1305

Wordpress exif plugin?
12 comments on page 230

Css login screen?
no comment on page 128

Htlm 5 photo gallery?
6 comments on page 1305

Css login screen?
no comment on page 128

Comments by intensedebate?
7 comments on page 1175

Image gallery html 5?
6 comments on page 1305

Wordpress andrew rickmann?
2 comments on page 1376

Wordpress medium large?
24 comments on page 1065

Fun with uninstallation wordpress?
53 comments on page 100

How to clear wp cache?
9 comments on page 1310

Photoshop frameworks?
3 comments on page 296

Html5 gallery?
6 comments on page 1305

Html 5 photo gallery?
6 comments on page 1305

Login screen css template?
no comment on page 128

Html5 photo gallery code?
6 comments on page 1305

Wordpress post multiple images?
24 comments on page 1065
  every 1990s, 1s ago, in 0.03s.
 __
(__)
   `
 Andrew Rickmann

Trisha,

I do agree with you. I am coming round to the fact that making things as easy as possible is the best solution.

The technical, ordered, part of me though wants to extend WordPress so that my plugin works in the same way as the core, but it seems that isn’t the best thing for the users.

 __
(__)
   `
 Trisha

I think adding a Settings would be better – the reason is that if you offer a template tag that needs to be inserted into a Theme file then SOME users will not be able to do this without messing up their Theme (a small minority, granted) however that still presents two other problems: 1) if the user switches Themes they will need to update every Theme they want to use, and 2) if the plugin is deactivated (for any reason) then the Theme can break – an invalid function call can prevent parts of the Theme’s files and styles from loading……..

 __
(__)
   `
 Andrew Rickmann

That’s a pretty interesting idea Kristin. One of my plugins uses ouput buffering to modify the code before it is output. In theory, it would be just as easy to load the file as a string, identify the relevent template tags, insert content before then and then eval the whole page.

I don’t think that is an ideal solution though, it is probably better for users to make a choice one way or another.

I have opted to go for the admin page simply because it is easier to explain to users.

 __
(__)
   `
 Kristin K. Wangen

The in-between could be to automagically add the code to the template, when the plugin is activated, and just tell your users that this is how it works.

 __
(__)
   `
 Andrew Rickmann

Kristin, that was what I was thinking but it did occur to me that an admin page for every plugin might get overwhealming and that adding lots of processing where you could just insert the tags could have an adverse effect if every plugin does it.

 __
(__)
   `
 Kristin K. Wangen

I think that you should as far as possible try to avoid any editing of template files. In my experience most people prefer the “upload the plugin and activate, and that’s all”-method.

I think the best solution would be both; you have an option page for the output, but if you want to edit template files you can do that.

 __
(__)
   `
 Andrew Rickmann

This is the sample comment.

You can see above that I am using WordPress 2.5.x. The statement is added using a template tag. Should I be aiming to add it automatically using choices from the admin panel? or are template tags a good thing?


0.01s