A few days ago, Glenn Bennett got in touch with me to let me know about a site called Widgetifyr.com. This site is a service which aims at making the WordPress widget creation process much easier than creating the code from scratch every time.
If you’ve ever tried to turn your code into a wordpress plugin (which is how WordPress widgets get installed) you know it can get a bit tedious. Our service lets you just paste your code into a form along with some addition information and we “magically” turn it into a WordPress Plugin that allows your widget to be used in WordPress.
Immediately I thought this was a cool idea. So I took it for a test drive to see if I could create a widget using a regular WordPress function such as get_posts. As it turns out, even a widget generator can stump me.
The way this works is that you create a plugin file which you can download at the end, upload it to your plugins folder, activate it and then use the widget. So the first part of the process deals with the basic plugin stuff such as the name, version, author, etc. At the bottom of this page is the important part. This is where you name your PHP Function Name. In the text area, you’re supposed to paste your PHP code which would reside between the brackets. Here is what mine looked like.
I used this code from the example shown on the codex related to this function. Once that was done, I clicked on the create button which takes the function, wraps it with the widget code and then gives me the chance to view the code in a txt editor to copy, paste in my favorite editor and than save that file as get_posts.php. I then uploaded this file to my plugins folder. Upon activation, I was greeted with a fatal error:
Parse error: syntax error, unexpected ‘}’ in public_html/wptavern/wp-content/plugins/get_posts.php.php on line 33
Here is line 33.
I received this error anytime I tried to activate a plugin I created. I’m not sure what I did wrong but after looking through the widgetifyr help page, to get a gist as to what the widget code is supposed to look like, and it’s obvious that you need to have a little PHP experience in order to really use this tool to its fullest potential.
The more I tinkered with the site, the more I realized that Otto’s Executable PHP Widget is a much easier, speedier solution for me. With this plugin, I can create widgets without having to worry about HTML or echoing anything. Here is one example of how I use this plugin.
No copying of code, no uploading, and it just works (as long as I put the function in correctly). If you’re a coder, let me know if the service makes it easier for you to create widgets. As for myself, I’ll stick with a Otto’s solution.