December 6, 2008

Following on from my post about Widget Management Concepts, I have produced a new plugin with the aim of making it super easy to include widgets within themes without needing to be concerned with writing plugins, or code in functions.php.

Installation

To install the plugin just download it and activate it. It has no options.

Creating Theme Widgets

Creating a theme widget really is very easy. Here is a step by step process.

Step 1

Create a new PHP file in the theme and call it {something}.widget.php.

Step 2

Add a PHP comment at the top of the file to indicate the name and description of the widget. Like this:

[php]
/*
Widget Name: 3 Random Posts
Widget Description: Outputs 3 random posts in a list
*/
?>

Step 3

Add the code you want for your widget. In this example I am adding code to output three posts at random:

[php]

Note that this code is identical to the code you would insert into a theme file to do this manually. There is nothing special about this code that needs to be changed to make it a widget.

Step 4

Assign the widget to sidebar.

workingwidget

On the left of the image is the output (there is only one post because it is a fresh installation) on the right the widget added to the sidebar.

Download

You can download the plugin from WordPress extend.

The Potential

I think that making it this easy to create, and more importantly understand, the widgets included with a theme opens up a lot of possibilities. For example, with this it would be easy to use a sidebar and widgets to offer different layouts for a featured post on the home page.

If you have any suggestions for improvements to the plugin itself, or ideas about how it can be used, let me know.



Wordpress title showing space?
no comment on page 1371

Wordpress fun?
one comment on page 1376

Live blogging plugin?
4 comments on page 1258

Wordpress 3 admin speed up?
4 comments on page 1321

Framework photoshop?
3 comments on page 296

Fun wp plugins?
one comment on page 1376

Habari vs wordpress?
12 comments on page 440

Wp tags vs categories?
12 comments on page 7

Wordpress rss seo?
one comment on page 1361

Photo albums html5?
6 comments on page 1305

Wordpress chat?
no comment on page 1308

Wordpress exif data?
12 comments on page 230

Css sidear tab?
2 comments on page 336

Wordpress theme html5 blueprint?
6 comments on page 1305

Wordpress shortcode in plugin?
no comment on page 236

Html 50 photo album?
6 comments on page 1305

Get the post attachement?
24 comments on page 1065

Wordpress plugin development 30?
one comment on page 1373

Wordpress plugin development 30?
one comment on page 1373

Disqus formatting?
7 comments on page 1175

Html5 photoalbum?
6 comments on page 1305

Html5 photoalbum?
6 comments on page 1305

Wordpress fun?
one comment on page 1376

Fun wordpress plugins?
one comment on page 1376

Url shortener ideas?
4 comments on page 1190

Url shortener ideas?
4 comments on page 1190

Html 5 photo gallery?
6 comments on page 1305

Multiple post navigation?
no comment on page 1147

Html5 photo galleries?
6 comments on page 1305

Adding images to a wordpress 3 post?
24 comments on page 1065

Html5 photo gallery code?
6 comments on page 1305

Wordpress multiple blog master?
one comment on page 1376

Wordpress 3 tableprefix?
2 comments on page 1374

Wordpress 3 tableprefix?
one comment on page 1376

Using wordpress as a framework?
2 comments on page 335

Single post image size?
24 comments on page 1065

Get featured image src wordpress?
24 comments on page 1065

Disqus wordpress mu?
7 comments on page 1175

Image gallery html 5?
6 comments on page 1305

Wordpress theimage?
24 comments on page 1065

Wpgetattachmentimagesrc size?
24 comments on page 1065
  every 1742s, 1s ago, in 0.02s.
 __
(__)
   `
 Andrew Rickmann

Can you paste the entire error in?

 __
(__)
   `
 Andy

I'm getting the Parse error: syntax error, unexpected T_STRING, expecting '(' in error too.

 __
(__)
   `
 Andrew Rickmann

I wouldn't recommend bundling plugins in with themes. Technically it is fine, but if the plugin is updated to cope with a new version of WordPress anyone using the theme would be stuck.

 __
(__)
   `
 Bret Holstein

I completely agree with your rationale for this plugin. It would make modifying themes and reusing components in different themes a whole lot easier if the theme widgets could be isolated into their own files.

Is there any reason why this couldn't be adapted to the functions.php file that comes with a theme? I'm not quite sure how it might be accomplished in practice but I would love to use the features of the plugin without requiring the users of my theme to load the plugin.

Any pointers on where to begin?

 __
(__)
   `
 Golden Retriever Puppies

Thanks for a great post, the plugin sounds of utility, I would want to give this a try.
Thanks for the step by step instruction would make it easy to get along on a fly..

 __
(__)
   `
 free satellite

Development of digital technologies occurs prompt rates. Does not lag behind progress and digital TV. Speaking about digital TV, we first of all mean satellite TV. The digital satellite TV becomes more and more accessible to simple users. The market paid satellite tv also is not necessary on a place. The new digital standard of TV of high clearness HDTV actively develops and takes root. The satellite TV becomes more and more directed on the spectator. Besides digital quality of the image, advantage of satellite systems also is also the extensive cover zone of the companion.

 __
(__)
   `
 pregnancy symptoms

I wish to wish all pregnant women of good mood, easy pregnancy and natural sorts! Good luck also are happy! Give birth easily and independently! Let not doctors give birth for you, and you! Also adjust itself on chest feeding of the kid! Read the necessary information! Be, lovely pregnant mums and expecting posterities of the daddy, are healthy and wise!

 __
(__)
   `
 Andrew Rickmann

Kevin, that sounds like you are running on PHP 4. I haven't included PHP4 support in this plugin; although, I don't think there is anything in it that wouldn't run on PHP4 except the constructor itself.

If you amend public function __construct(){

to read

function fw_theme_plugins() {

then that might work. I haven't tested it though.

 __
(__)
   `
 Kevin Sandridge

Hi – any reason this plugin might not work with WP 2.7? Getting the following error code when I try to activate it:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /mnt/local/home/fmblogger/floridamortgageblogger.com/wp-content/plugins/fun-with-theme-widgets/fun_with_theme_widgets.php on line 31

 __
(__)
   `
 My experience of Flexx – WP FUN

[...] type of post (journal entry or photos) and as such had some extra code to output that. I used my Fun with Theme Widgets plugin to convert this to a widget and then attached it to the [...]

 __
(__)
   `
 Jazzthedog

Great plugin!

It's a great way of collecting your favorite snippets of code you would normally use and all of a sudden..it's a widget!

A couple of minor issues.

1. I tested this out within a 'child' theme and I had to copy the php file to the 'parent' theme to get it to show up in the GUI.

2. After adding it to the widget section , I could not click on edit to remove it. I had to deactivate the plug.

I can imagine after adding many of these widgets, with the current GUI implementation of widgets in WP 2.7 will become quite painful. Perhaps WP 2.8 will make it better.

 __
(__)
   `
 WordPress Plugin Releases for 12/08 | BlogBroker24-7

[...] Fun with Theme Widgets [...]

 __
(__)
   `
 Bloodhound Scenius in a Widget | Real Estate Blog Lab

[...] I found a new plugin for building Theme widgets called Fun With Theme Widgets [...]

 __
(__)
   `
 leg med nye medier. Eller noget.

[...] Fun with Theme Widgets – WP FUN (tags: wordpress plugin widget) [...]

 __
(__)
   `
 Andrew Rickmann

Monika,

Trackbacks are a nice idea, but in practice I got so much spam and so many one line links that it wasn't worth it.

I am happy for you to add your link in any comments here, especially when you are promoting something I have done :-)

 __
(__)
   `
 Monika

oh my dear Andrew

it sounds that I'm silly but I'm only confus this day because it is monday, since many years Murphey is the best guest at monday :(

… ok I try to write … Hi best coder … (thats better than 2time the false name )

ok you do not accept pings and trackbacks – so there is no chance to create a good network –
I have sent a ping not a trackback ;)

thanks for your answer Andrew ;)

 __
(__)
   `
 Andrew Rickmann

Actually, It's Andrew. And the reason is that I've turned off trackbacks because, in the whole, people don't see the value in them.

 __
(__)
   `
 Monika

oh Ryan .. your name is Ryan not Rick …your name is Ryan not Rick and I hope you will delete this ..
it is monday ..sorry :(

 __
(__)
   `
 Monika

Hi Rick – I know this comment is offtopic but I don't know where I can ask…

I've sent a ping but I can't see it? Why? Is this the *blog comments powered by.*…. ?

kindly regards
Monika

 __
(__)
   `
 WordPress Plugin Releases for 12/08  | Wordpress Blog NL

[...] Fun with Theme Widgets [...]

 __
(__)
   `
 WordPress Plugin Releases for 12/08 | bloground.ro – Blogging resources, WordPress themes and plugins for your development

[...] Fun with Theme Widgets [...]

 __
(__)
   `
 einfachst neue Widgets erstellen und nutzen-WP-Plugin

[...] WordPress Plugin Fun with Theme Widgets herunteladen. Dank dafür geht an Andrew [...]

 __
(__)
   `
 Andrew Rickmann

Ryan, come back and let me know if you do. I would love to see what this could do.

 __
(__)
   `
 Ryan

Thanks Andrew :)

I might adapt this for a new theme I'm creating.


0.02s