Creating a WordPress Widget
Many of you have wonder about the making of WordPress widgets. It’s quite easy to do.
Of course, you need to have the PHP scripts of your application already coded and preferably styled correctly.
Allow me to take the example of tizozote – Refer to: http://blog.fadil.fr/2009/08/20/making-a-simple-twitter-client-using-php-tizozote/
Knowing that the script which contains my main form is tizozote.php, I’ll re-code it to fit wordpress. The plugin will be called wptizozote and the script will be saved as wptizozote.php.
So, wptizozote.php will contain the following piece of codes.
*Adding the description*
<?php /* Plugin Name: WPtizozote Plugin URI: http://blog.fadil.fr/2009/08/20/creating-a-wordpress-widget Description: Ene ti widget pou zozote (tweet) online Author: Fadil Version: 1.0 Author URI: http://blog.fadil.fr */
Refer to tizozote.php – *adding the following*
function wptizozote_widget() {
require_once('functions.php');
if (isset($_POST['posted']) && $_POST['posted'] == 'yes') {
echo "
Message: ".$_POST['tweet']."
";
echo "Wee Messaze la fine zozoter!
";
tweet($_POST['twitter_username'],$_POST['twitter_password'],$_POST['tweet']);
} else {
echo "
Now, I add the form codes.
<form action='tizozote.php' method='post'> <p><label for='twitter_username'>To nom ta zozo:</label> <input type='text' name='twitter_username' id='twitter_username' /></p> <p><label for='twitter_password'>Done to pass:</label> <input type='password' name='twitter_password' id='twitter_password' /></p> <p><label for='tweet'>Tape to zozote:</label> <textarea name='tweet' id='tweet' maxlength='140'></textarea></p> <input type='submit' value='Zozote'/> <input type='hidden' name='posted' id='posted' value='yes' /> </form> "; }
It’s not over yet. I need to make the bloody thing appear in the widget section ready to be added to the WP sidebar.
function init_wptizozote(){
register_sidebar_widget("wptizozote", "wptizozote_widget");
}
add_action("plugins_loaded", "init_wptizozote");
?>
Done!
In case you do intend to write as above and use wptizozote.php, do copy functions.php and twitter.php to your root folder.
Copy wptizozote to wp-content/plugins. Go to your wordpress dashboard and plugins page to activate wptizozote plugin. Head to the widgets section and drag wptizozote to your sidebar. Tweak the bloody tizozote and have some fun.
Like I mentioned earlier, if you’ve the scripts to your application, turning it into a WP widget is not hard at all. Still find it hard? Go through tizozote.php and compare the codes to the above. The differences are self-explanatory.
No comments yet.
2KX
December 31, 2009 - 8:42 pm
Tags: 2010, 2010 = 2kx, 2kx, box.net, dropbox, Facebook, Flickr, Google Wave, googledocs, pro, twitter, ustream, year, youtube, zest, zipline, zoho online, zooomr
Posted in Personal | 3 comments
This is a short post for I am very busy with many projects. And yes, I do not celebrate new year. For me, 2KX is a “switch year!” (What? It’s not a leap year!) I am switching from Flickr [ http://flickr.com/ ] to Zooomr Pro [ http://zooomr.com/ ] (Zest FTW & the Zipline is pretty much [...]
Twitter Lists = EPIC FAIL (Reloaded)
November 2, 2009 - 6:39 am
Tags: Channels, Content, Epic, Fail, Lists, tweeps, twitter, users
Posted in Computing | 1 comment
Check out my newly created Twitter lists. In which of the above lists do you wish to be listed? See! You never categorise users of a ‘content spread network.’ Oh, I like the term! [CSN] You categorise content! Twitter is wrong. Channels PWN lists. Refer to [ http://blog.fadil.fr/2009/10/30/twitter-lists-epic-fail/ ] I’m off to delete those lists! [...]
Twitter Lists = EPIC FAIL
October 30, 2009 - 8:42 am
Tags: categorise, category, channel, Channels, Content, Epic, Fail, Group, Jaiku, Lists, microcontent, trends, twitter
Posted in Computing | 8 comments
While the likes of Scobleizer [ http://scobleizer.com/] and Carrotmadman6 [ http://themediaguru.blogspot.com/ ] love Twitter Lists, I find this feature to be a pointless one. What is the Twitter Lists feature? – Grouping of contacts under categories (public + private) + displaying the latter’s last tweets. What is Twitter all about? – Spreading textual microcontent. Dear [...]
How to install the WordPress 2.9b?
October 18, 2009 - 7:25 am
Tags: 2.9, beta, bleeding edge nightlies, Peter Westwood, Point release nightlies, wordpress, wordpress 2.9, Wordpress Beta Tester
Posted in Computing | 1 comment
Fancy testing the beta releases of WordPress 2.9? Peter Westwood’s WordPress Beta Tester plugin makes the process easy. Check out: [ http://wordpress.org/extend/plugins/wordpress-beta-tester/ ] After installing the plugin [Copying the bloody files to wp-content/plugins/ and activating the plugin], navigate to Tools-Beta Testing. Choose between point release nightlies and bleeding edge nightlies. Or head on to wp-admin/update-core.php [...]
@orangemauritius = Success!
October 12, 2009 - 2:51 pm
Tags: @orangemauritius, audience, insults, mauritius, notification, orange, outgroup, relationship, social network, tweeps, tweets, twitter
Posted in Computing, General Chats | 1 comment
Ever since Orange has been on Twitter [ @orangemauritius] , many Mauritian tweeps have bashed it. The tweets consist of insults. It is surprising to take note that Orange has only 34 followers as of now but the insults flow in the Twitter stream every day. This is a huge success for Orange has been [...]
“Twitter for Business” – It’s something old.
October 1, 2009 - 4:01 pm
Tags: adoption, business, jetblue, Jude Umeh, microcontent, organisation, twitter, wholefoods
Posted in Computing | No comments
Jude Umeh wrote an interesting blog entry entitled “Twitter for Business, or is it. Really?” [ http://www.bcs.org/img/server.php?show=conBlogPost.1438 ] Do read it. I do not share his skepticism about the use of microcontent and micromedia in the business world. Extract: Perhaps I am just being impatient and this will come to pass in time, as in [...]
The basic HTML Twitter widget is no longer featured on twitter.com/widgets
September 21, 2009 - 6:19 pm
Tags: Basic HTML widget, styles, twitter, widget
Posted in Computing | 1 comment
Stacy just told me that Twitter has removed the basic HTML widget from its widgets page. Instead, there is another styled and embeddable one. It’s not that bad. Anyway, if you crave for the previous widget, here it is the embeddable piece of codes. Replace “yourusername” by your Twitter username. <div id="twitter_div"> <ul id="twitter_update_list"></ul> <a [...]
My Top 3 Online Female Celebrities
September 13, 2009 - 10:08 pm
Tags: ana kasparian, cali lewis, CaliLewis.me, celebrities, Dear Cali, Facebook, geek, geekbrief.tv, iCali, IPOWER, lucria petrucci campbell, nee, nerd, online, tania derveaux, The Big Trip, the young turks, twitter, tyt, Virb, Wrath of the L337 King, youtube
Posted in General Chats, Personal | 3 comments
My top 3 online female celebrities: 1. Tania Derveaux She is a very good tweep/YouTube friend of mine. She stars in athenewins and is currently working on a movie review programme for a TV station. More information about her projects are being unveiled on her Twitter page. Tania is funny, brilliant, and is a gamer. [...]
Just fooling around with Google Gadgets.
September 5, 2009 - 1:48 am
Tags: blog, google gadgets, iGoogle, javascript, mobilepress, wordpress, xml
Posted in Computing | 1 comment
I’m unsure as to how many people use iGoogle though. Anyway, iG is JS heaven! To the WP bloggers out there who want to add their fully functional blogs within a Google Gadget quick and easy, install MobilePress plugin and iframe the URL of your blog [followed by this tag without quotes "?mobile"] in the [...]
Google Mauritius Day 2009 – Event 2 – #GMDE
September 4, 2009 - 3:01 am
Tags: #GMDE, appengine, Businesses, Enterprises, Entrepreneurs, Event 2, G-Mauritius, google, Google Mauritius Day 2009, twitter
Posted in Computing | No comments
Time Activity 0900-0930 Registration, Coffee, Snacks 0930-1030 Keynote (key concepts and trends in internet growth – personalisation, etc) 1045-1130 Adwords & Adsense – Advertise and make money 1145-1230 Google Analytics & Website Optimizer – the importance of testing 1215-1300 Google App Engine 1245-1330 Search 101 – a great website is nothing without search results 1330-1430 [...]
