DD Favourite Posts – how to list your favourite posts on WordPress

February 6th, 2011

We have latest posts, or most commented posts, or even popular posts plugin – which all provide easy widget. Just drag and drop and wushhh.. those list now on your main page sidebar.

After a small modification requested by a client, I have an idea of publishing the favourite (favorite?) posts plugin. It will allow you to select your favourite posts to be highlighted on the main page. They will be sitting until you remove them. Yes, sticky posts I can say in forum-based language.

So have a check it’s here:

http://wordpress.org/extend/plugins/dd-favourite-posts/

WP Plugin & SVN

February 6th, 2011

The long story at WP “Using Subversion” is not for everyone, at least not for Windows user with limited Linux knowledge.

So how do you actually put your plugin on WordPress and make it searchable and updatable via self-hosted WordPress dahsboard?

Let me put it this way.

1. You need to have a repository account. Apply here.

2. Download and install Tortoise SVN.

3. Create a SVN folder in your PC (any names). Right click and SVN Checkout. You will get 3 directories trunk, tags, and branches.

4. Fill trunk with your plugin files, make sure readme.txt comply with requirement. Use validator here.

5. Right click on trunk and Commit. Make sure all the files checked on the prompted windows.

6. Right click on trunk again, pick TortoiseSVN/Branch/Tag. Replace trunk with tags/1.0 (or your stable version in readme.txt)

7. Right click on tags and SVN Update

That’s it.

For more details and graphical view, visit this entry.

jquery.min.js & prototype.js – conflict and resolution

February 5th, 2011

While I was writing a WordPress plugin for a client, it came to a situation where I need to use both jquery.min.js & prototype.js and this result in a conflict. After googling around I found this page citing the same problem. Still no luck after trying the suggested solution (jQuery.noConflict();).

It is the link in the comment from Ahsan Shahzad which save my day. Thanks!

Since both script use $()-function, I just need to be more specific on my jquery lines by adding adding the jQuery(function($){ bla; }); portion.

IE Error: Unterminated string constant

January 25th, 2011

So I found this error when viweing my intra application with IE7. No error with Mozilla Firefox.

After some debugging, I know the error come out from the onmousemove event. It is not specifically from this event alone, actually it is from a database content which is passed to this event. One of my user type in a special character, and when the string is passed to onmousemove event, it trigger an error such as the string is incomplete.

How to capture full web page as image

January 21st, 2011

There is a free mozilla firefox addon which can be used for this, checkout ScreenGrab here.

I found it to be very useful especially when loading a lengthy web page.

How to move large sql file to new server

January 18th, 2011

Normal method that I do:

1. From phpmyadmin, click on database, export, save as file, then download the file into my computer.

2. On new server, from phpmyadmin, import, browse to the file downloaded from #1

That is fine for small file. Even though it says 50Mb is OK, but it will depends on the connection speed as well. I tried 27Mb and it’s not working.

So I tried another method:

1. From cpanel on old server, click to backup wizard, click backup, pick mysql databases, select the table, then the download will start.

2. Using my FTP client, upload the *.gz from Step 1 to a folder on my new server. Any folder.

3. Login to SSH, use this command:

gzip -d database_file_name.gz

So it turns to:
database_file_name.sql

4. Then use this command to restore database:

mysql -u user -p new_database_name < database_file_name.sql

Please note that new_database_name is created in advance using phpmyadmin on new server.

Facebook ‘like’ button for wordpress

January 16th, 2011

Adding Facebook ‘like’ button may not be as difficult as you may think. I added it manually without a plugin and only need to update 2 theme file. Before that, I would like to mention that, adding the ‘like’ button be it XFBML or an iframe, it is very straight forward;

1. No need to update the <head> part of a document

2. No need to create Facebook application

I wrote it down because I read a lot of articles asking people to do both of things above, while in fact I did it here on this blog without those. I am not sure why, perhaps Facebook does upgrade the method and it cut down half of the hassle in adding a simple ‘like’ button.

So, let’s digging.

You just need to update 2 files which are single.php, and footer.php. Before that, please get the ‘like’ button code here, I suggest the XFBML and not the iframe, becuase XFBML is so flexible and you don’t need to supply your post permalink for each of the ‘like’ button.

1. Get the ‘like’ button code here. Just hit ‘get code’ and choose XFBML. It will be something like this:

<script src=”http://connect.facebook.net/en_US/all.js#xfbml=1″></script><fb:like show_faces=”true” width=”450″>

</fb:like>

2. Open single.php (Dashboard>Appearance>Editor), find a line something like this;

<h2><?php the_title(); ?></h2>

Enter the code after that line.

3. Open footer.php, find this line

</body>

Just enter this code before that line:

<div id=”fb-root”></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: ‘your app id’, status: true, cookie: true,
xfbml: true});
};

(function() {
var e = document.createElement(‘script’); e.async = true;
e.src = document.location.protocol +
‘//connect.facebook.net/en_US/all.js’;
document.getElementById(‘fb-root’).appendChild(e);
}());
</script>

Yes I did not fill up ‘your app id’ and it’s working.

Good luck.

Greenshot for print screen

January 16th, 2011

This is a quick bookmark on a free tool for rectangle screen capture. Convenience for use.

http://getgreenshot.org/downloads/

How to upgrade your wordpress and not getting blank page

January 10th, 2011

First of all, you really need to read this manual. I have never do, that’s why I never get my wordpress automatic updates work for me. As long as I see the new version on top of the dashboard, I will click on update now and end up in frustration because it just hanging there and no result or error messages. And I will go back to the normal manual upgrading.

Now, to make the auto upgrade works, just disable all your plugins, hit the upgrade wordpress button. You will get your blog updated to latest version and don’t forget to activate the plugins back.

Easy.

Creating external WordPress Page

January 3rd, 2011

There are times when we need to create a fresh blank page for our WP which does not contain any header, footer or sidebar. Just put this PHP line:

require_once(‘./wp-blog-header.php’);//same folder with WP main files

Example:

<?php
require_once(‘./wp-blog-header.php’);
query_posts(‘showposts=5′); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h2><a href=”<?php the_permalink(); ?>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?></a></h2>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>