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.

Wpunlimited The Ultimate Wordpress Theme
Html5 wordpress?
3 comments
page 1141
Fun With Theme Widgets
Funy photo widget?
24 comments
page 867
Quick N Dirty Admin Login Screen
Login page css templates?
no comment
page 128
Wpunlimited The Ultimate Wordpress Theme
Html5 wordpress?
3 comments
page 1141
Quick N Dirty Category Redirection
Wordpress redirect category?
no comment
page 133
Post Image The Easy Peasy Way
Wordpress attach image to multiple posts?
26 comments
page 1065
Using Your Own Url Shortener
Wordpress clear rewrite rules?
4 comments
page 1190
Premium Ithemes Review Photo Gallery
Ithemes review?
4 comments
page 226
Updating Code Snippets Here
Wordpress fun plugins?
one comment
page 1338
Updating Code Snippets Here
Wordpress fun?
one comment
page 1338
Theming Habari Vs Wordpress
How to design a habari theme?
13 comments
page 440
Why I Ditched Disqus
Disqus email?
5 comments
page 1175
Html 5 Gallery
Themeatic html5?
6 comments
page 1305
Post Image The Easy Peasy Way
Wordpress first image?
26 comments
page 1065
Quick N Dirty Admin Login Screen
login screen using css?
no comment
page 128
Html 5 Gallery
Picture gallery html5?
6 comments
page 1305
Post Image The Easy Peasy Way
Wordpress first image gallery?
26 comments
page 1065
Post Image The Easy Peasy Way
Resizing images in thecontent?
26 comments
page 1065
Html 5 Gallery
Html 5 photo gallery?
6 comments
page 1305
Post Image The Easy Peasy Way
Inserting an image url in comments?
26 comments
page 1065
Post Image The Easy Peasy Way
Wp attachment functions?
26 comments
page 1065
Dont Mess With My Toot Toot
Wordpress custom content?
16 comments
page 599
Using Your Own Url Shortener
String shortner?
4 comments
page 1190
Quick N Dirty Admin Login Screen
My admin login page?
no comment
page 128
Using Your Own Url Shortener
How to build a shortner link?
4 comments
page 1190
Post Image The Easy Peasy Way
Get post attacments?
26 comments
page 1065
Theming Habari Vs Wordpress
Habari vs wordpress?
13 comments
page 440
Are Child Themes The Best Option
Wp child themes?
15 comments
page 1262
Upload From Url
Upload to url?
6 comments
page 326
Silence Is Golden
Silence is golden wordpress?
3 comments
page 213
How To Add Sidebars To A Theme
Html hot add a side bar?
10 comments
page 1053
How To Add Sidebars To A Theme
How to add picture to the wordpress sidebar on sidebarphp?
10 comments
page 1053
Fun With Sidebar Tabs Styling
Position of the tabs thematic?
2 comments
page 336
  1 query every 1487 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 [...]