WordPress Plugin: Basic Facebook Social Plugins

Today, I saw that Facebook introduced some new features, and one intriguing feature is called “Facebook Social Plugin“. It would be very interesting to have blog posts to be simply “liked”, and having information displayed about activities and recommendations related to your website.

So I decided to take 30 minutes of my break time and write this simple plugin. Since I don’t have much time I decided not to explore XFBML and the SDK as yet. That is why it’s called BASIC. With XFBML, shorter codes can be used, and deeper integration between Facebook and your website can be achieved. I am intrigued, really but I must be realistic.

This plugin is a very simple plugin to embed :

  1. “like” button at the end of your articles/blog posts
  2. activity feed as a widget
  3. recommendations as a widget
  4. Like box as a widget

You can add these cool features with minimal effort.

Most configuration parameters are self-explanatory, but Domain Override simply means you want to display information about another domain instead of where the widgets are hosted. By the way, the widget settings are combined in the Settings > Basic Facebook Social Plugins page.

At this moment this plugin is still waiting to be hosted at the official WordPress Plugin Directory so it can only be downloaded here.

  • Basic Facebook Social Plugins Version 1.0
  • Basic Facebook Social Plugins Version 1.1 * This version will wipe out previous widget settings as it introduces multiple instances of widgets.
  • Basic Facebook Social Plugins Version 1.2

Once available there, a link will be provided. When it’s there, It’s now in the official plugin directory (basic-facebook-social-plugins) so you should be able to install it using the automated, built-in plugin installer too.

You can see the sample for the like button at the end of this post, and the widgets live on this site.

The widgets does not conform to your theme (does not inherit your theme css) but simply bare boxes with Facebook feel. Take note that styling inside the boxes (and texts) are provided by facebook.

Those of you who are concerned about privacy, you’ll be glad to know that your name and profile picture will not just be displayed to anyone:

25153_430469086728_20531316728_5233502_2779746_n

(This also applies to recommendation and activity box. Only friends will be able to see that you like something.) Facebook has thought of everything.

Try it out and let me know how it works for you.

Shots from Facebook:

25153_430468906728_20531316728_5233495_6137188_n

25153_430468866728_20531316728_5233494_4789969_n

Facebook has also written a nice post about social plugins in their blog: Answers to Your Questions on Personalized Web Tools.

Note:

  1. This WordPress plugin is written entirely by me, and is provided as-is with no guarantee. It is neither approved nor endorsed by Facebook.
  2. Yes, it is breakable by Facebook if they decide to change the iframe URL.

Subscribe To Comments

I am a blogger. (What a stupid statement when writing a blog post). Anyway, I just wish everyone could install the Subscribe To Comments plugin so that I will know when they (or anyone for that matter) responds to my comments.

Today I have to remember which blog post I posted my comments on and wait for it to load. Yes I know I am just being lazy.

Trust me, it helps your reader. And for what it’s worth loyal visitors will still need to load the post page to see your respond. That is traffic for sure.

The best thing of all is that it is virtually maintenance free. You can manage it if you need to but from my experience using it for more than a year I don’t need to do anything.

I would also like to ask that visitors to this blog tick the subscribe checkbox if they are asking questions. It’s much more convenient plus you’ll know when I respond. Unsubscribe link is always provided in the emails you will receive.

Happy WordPressing.

WordPress Plugin: Collapsible Archive Widget

Update: 20 January 2010: This plugin has not been tested with WordPress 2.9 and may break because 2.9 has internal changes. I am still trying to find time. Sorry for the Inconvenience.

I have written another simple WordPress plugin that simply display a collapsible archive in the sidebar. You can see it in action in the rightmost sidebar of the main page.

When the sidebar loads, it is in collapsed state and can be expanded by clicking the years. It utilizes simple JavaScript that shows and hides a div containing the monthly links. The purpose of this plugin is to save space on the sidebar especially if you have been blogging for a while. It is an alternative to the combo box (select) provided by the default archive widget.

My request for the plugin to be listed in the WordPress Plugin Directory has been pending for a while so for now it can be downloaded here.

The plugin can now be downloaded here.

Configuration:

  • Widget Title: the title of the widget
  • Show post counts for year: Whether or not to show the post number for each year
  • Show post counts for month: Whether or not to show the post number for each month
  • Abbreviate month names: Check this box to show abbreviation of month names
  • Hide year from month names: Do not print year after month names
  • Use script.aculo.us effects: Whether or not to show effects
  • Expand effect: Effect to use when expanding the list
  • Collapse effect: Effect to use when collapsing the list
  • Expand the list by default: Check this box to have the list expanded when loaded
  • Expand current year by default: Check this box to have the current year expanded when loaded
  • Expand current month by default: Check this box to have the current month expanded when loaded
  • Show individual posts: Show posts in the list. This should be used in extra caution; if you have a lot of posts consider disabling it as this will take time to load
  • Use HTML arrows instead of images (► ▼)
  • Show current month in bold: show current month in bold
  • Show a link to plugin page. Thank you for your support! : Display a link to plugin page (this page) as a support method

Current Version: 2.3.1

Installation

Copy the file to the wp-content/plugins/widgets directory and activate it in the Plugins page. Then drag and configure it in the Sidebar Widgets page.

Warning: Will only work on widgets enabled blogs.

TODO (these are being considered but there is no guarantee when they are going to be included)

  • Add ability for multiple instances
  • Add ability to work as non-widget
  • Add ability to include / exclude categories
  • Expand previous month rather the current
  • Research the practicality to use CSS / allow CSS options
  • List posts without year and month headers (for blogs with few posts)
  • Do not list the posts that are listed on the main page

Change Log

  • 03-Aug-2007: Initial version
  • 04-Sep-2007: Added ability to select whether to use abbreviations for the month names, and script.aculo.us effects!
  • 27-Sep-2007: Fixed javascript include – effects.js added and scriptaculous.js removed (For some reason it worked in 2.2)
  • 10-Nov-2007: Added ability to display posts (with caution), to expand by default, and also added plus and minus signs as expand/collapse buttons
  • 24-Aug-2008: Multiple updates:
    • Enqueue javascripts using WordPress API wp_enqueue_script
    • Validation as XHTML 1.0 Transitional
    • Add option to expand current year and/or month by default
    • REMOVED list type option
    • Added ability to upload own plus and minus images
    • Added ability to display plugin link. If you’d like to support this plugin, having the “powered by” on your blog is the best way; it’s our only promotion or advertising.
  • 25-Aug-2008: Bugfix to not load javascripts when effects is not used
  • 25-Aug-2008: Javascript code factoring and added ability to use HTML arrows
  • 16-Mar-2009: Separated year and month posts counts, added option to hide year after month names, ability to show current month in bold, enabled localized title
  • 17-Mar-2009: Fixed valid XHTML, and highlight (bold) bugfix


BIG FAT WARNING

The ability to display posts is provided after receiving so many requests for it. This feature is not practical for those with many posts in a month. Enabling it means that there is a lot more data that needs to be received by the browser, not to mention the load on the database. It is, however works very nice for blogs with low post count. Please use at your own risk and remember to test it.

Notes:

11-Nov-2007: I’d like to thank Meitar Moscovitz who tried his best to provide a patch to display posts in the list. I rewritten some of the code for version 2.1 based on his logic. Thank you!
25-Aug-2008: Thanks to Berny for his idea of re factoring the javascript code and also for providing HTML arrows option.

If you find this plugin useful, feel free to


WordPress Plugin: Random Posts Widget

My better half was complaining that she can’t find a suitable plugin for displaying random posts on her sidebar. I tried to look myself, and there were some references to the plugin but nowhere to be found. One good plugin I found is Random categories with random posts by Mike Stickel but it uses categories which is not what we are looking for. Also, it requires tinkering with PHP codes which is not suitable for less technical bloggers.

So I went to analyze his code for a little while. What the heck, I’ll just create a simple widget version with no categories involved. So I took about 30 minutes to write this simple code with not so many options. It is a widget and configurable in the Sidebar Widgets page:

Random Posts Widget configuration

  • Widget title: the title of the widget
  • List types: ul for bulleted list, p for paragraph, br for paragraph with line breaks
  • Before title and After title: you have to find out what your theme uses before and after the widget headers. A simple way to do this is to identify a currently existing widget in your site and viewing the source. Find the title and see what is printed before and after. For example it might show as <h2>Widget Title</h2> which is used by most themes.
  • Post count: Number of random posts you would like to be displayed

Basically that’s it. It’s really a simple widget.

I don’t like to reinvent the wheel but since I can’t find any I just have to create one myself. Most probably I will have not so much time to maintain this plugin, but it is suitable if you are looking for a (very) simple plugin to display random posts.

You can download it from WordPress Plugins Directory: Random Posts Widget, or view online here: randomposts.php

Current Version: 1.5.0

Installation

Copy the file to the wp-content/plugins/widgets directory and activate it in the Plugins page. Then drag and configure it in the Sidebar Widgets page.

Warning: Will only work on widgets enabled blogs.

Change Log

  • 07-May-2007: Fixed a bug of displaying widget before and after tag
  • 14-Jun-2007: Fixed a bug where pages are also selected. Now it only displays posts.
  • 26-Jun-2007: Removed before and after configuration options, now taken from theme settings. Was broken for some themes with embedded class in the header tags. Reported by Guohua. Thanks.
  • 03-Aug-2007: Overhauled entire engine to optimize queries. This has been tested on a test blog with 50,000 posts on an old machine (Pentium III 600MHz) in maximum 3 seconds. Also removed duplicated results and added category to choose.
  • 04-Aug-2007: Fixed a bug where wrong permalink was displayed.
  • 10-Aug-2007: Fixed a bug where if 1 post count is selected an error occurred.
  • 27-Sep-2007: Added ability to detect database version (WordPress 2.3 has database changed) while maintaining backward-compatibility with 2.2.x

About The New Blogger Import Plugin

I wrote a plugin to import everything that can be found from the feeds Blogger provides. Many people has emailed me since asking me why I would do such a thing, as Blogger is a great platform for bloggers. This is my answer to all of those questions.

Why do you write this script/plugin?

A simple answer to this is that my better half wanted to migrate to WordPress and she has accidentally accepted the offer to upgrade to the New Blogger (Blogger Beta back then). Next, I was looking for ways to maintain my coding skills in PHP as for the past 3 years I have been working in System Administration and security.

Do you hate Blogger/Google that much?

No I don’t hate them. In fact, I love Google so much that I am willing to work for them if given the chance 😉 I love all Google products, but when it comes to blogging I feel restricted using Blogger. I migrated my blog from that system when it had only two posts. I hope Google does not think I hate them (perhaps that’s why my pagerank stays static).

Why don’t you integrate the Haloscan import into your plugin?

Why should I re-invent the wheel? Justin has written a very good tool to do this.

Do you think it’s suitable to call it a plugin?

No. Other plugins will be used and upgraded as time goes but for this one, you can remove it after you’ve finished importing. Call it a disposable plugin if you desire.

Will this plugin work forever?

No. If Google decides to change a tag inside the feeds, the whole plugin will fall apart. When that time comes, I might or might not have the time to provide an immediate fix. So if you want to do it, I suggest not to wait.

I’ll add my answers from time to time to this post, if I receive any more. Till then, have a nice weekend.

Google Analytics Plugin Not Showing

Well, this is not a complaint to the great plugin, but for some themes.

Themes like Intense, and AquaGreen does not have any wp_footer call so the tracking code will not show. How to fix it?

Open up themes/[themename]/footer.php and add <?php wp_footer(); ?> before </body> resulting in:


<?php wp_footer(); ?>
</body>
</html>

Hope this helps. I discover this after 5 minutes of head scratching. 😉