888888.888888.88""Yb..dP"Yb..8888b..Yb..dP.88b.88....db....8b....d8.88..dP""b8..dP"Y8
88__...88__...88__dP.dP...Yb..8I..Yb.YbdP..88Yb88...dPYb...88b..d88.88.dP...`".`Ybo."
88""...88""...88"Yb..Yb...dP..8I..dY..8P...88.Y88..dP__Yb..88YbdP88.88.Yb......o.`Y8b
88.....888888.88..Yb..YbodP..8888Y"..dP....88..Y8.dP""""Yb.88.YY.88.88..YboodP.8bodP'


88b.88.888888.888888.Yb........dP.dP"Yb..88""Yb.88..dP
88Yb88.88__.....88....Yb..db..dP.dP...Yb.88__dP.88odP.
88.Y88.88"".....88.....YbdPYbdP..Yb...dP.88"Yb..88"Yb.
88..Y8.888888...88......YP..YP....YbodP..88..Yb.88..Yb

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.

Converting Wordpress Themes To Habari
Habari timthumb?
one comment
page 694
Fun With Sidebar Tabs Styling
Tabs with html css on same page javascript?
2 comments
page 336
Using Your Own Url Shortener
How to have own url short?
4 comments
page 1190
Post Image The Easy Peasy Way
Insert conditional image php wp?
26 comments
page 1065
Using Your Own Url Shortener
Run short url using htaccess?
4 comments
page 1190
How To Add Sidebars To A Theme
Wordpress sidebar above main sidebars?
11 comments
page 1053
Html 5 Gallery
Html5 simple wordpress theme?
6 comments
page 1305
Dont Mess With My Toot Toot
New posttype not displayed wordpress?
16 comments
page 599
Quick N Dirty Replacement Text
Wpupdatepost object?
no comment
page 122
Updating Code Snippets Here
Fun wordpress plugin?
one comment
page 1338
How To Add Sidebars To A Theme
Wp register sidebars?
11 comments
page 1053
Html 5 Gallery
Html5 wordpress theme?
6 comments
page 1305
Post Image The Easy Peasy Way
Get post images?
26 comments
page 1065
Updating Code Snippets Here
Wordpress fun plugins?
one comment
page 1338
Post Image The Easy Peasy Way
Wordpress get first image large?
26 comments
page 1065
Using Wordpress As A Php Framework
Wordpress create your own framework?
2 comments
page 335
Improve Your Typography With Plugins
Wordpress typography plugin?
one comment
page 721
Quick N Dirty Replacement Text
Dirty replacement?
no comment
page 122
How To Add Sidebars To A Theme
How to add pages in footer wordpress?
11 comments
page 1053
Post Image The Easy Peasy Way
How to post all gallery images in one post wordpress?
26 comments
page 1065
Post Image The Easy Peasy Way
Get attachment by post?
26 comments
page 1065
Html 5 Gallery
Html 5 tab?
6 comments
page 1305
Wordpress 25 Exif Fields
Exif info display wordpress?
12 comments
page 230
Using Your Own Url Shortener
Tiny urls htaccess?
4 comments
page 1190
Six Million Ways To Die Choose One
6 million ways to die so i chose?
14 comments
page 1128
How To Add Sidebars To A Theme
Wp register sidebars?
11 comments
page 1053
Fun With Sidebar Tabs Styling
Funwithsidebartabs customize css?
2 comments
page 336
My Experience Of Flexx
Flexx theme review?
4 comments
page 1026
Wpunlimited The Ultimate Wordpress Theme
Ultimate admin theme?
3 comments
page 1141
Quick N Dirty Admin Login Screen
Css login screen?
no comment
page 128
Fun With Sidebar Tabs Styling
Css tabcontentcontainer?
2 comments
page 336
Html 5 Gallery
Html 5 e wordpress?
6 comments
page 1305
Dont Mess With My Toot Toot
Toot html5?
16 comments
page 599
  1 query every 1306 seconds, updated 1 seconds ago.
Sunday, 10am
 __
(__)
   `

 Andrew Rickmann

Can you paste the entire error in?

Sunday, 8am
 __
(__)
   `

 Andy

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

Thursday, 7pm
 __
(__)
   `

 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.

Thursday, 7pm
 __
(__)
   `

 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?

Monday, 1pm
 __
(__)
   `

 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..

Saturday, 5pm
 __
(__)
   `

 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.

Wednesday, 8pm
 __
(__)
   `

 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!

Saturday, 1am
 __
(__)
   `

 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.

Saturday, 1am
 __
(__)
   `

 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

Friday, 11am
 __
(__)
   `

 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 [...]

Saturday, 1am
 __
(__)
   `

 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.

Wednesday, 12pm
 __
(__)
   `

 WordPress Plugin Releases for 12/08 | BlogBroker24-7

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