How to Optimize Your WooCommerce Store for Single Product/Item Checkout

The buying process on a WooCommerce store for most goes like this:

  • The user spots a product
  • He adds it to the cart
  • He goes to the checkout page
  • He pays for it

What if we could get rid of the cart altogether and provide a more friendly user experience instead of this Walmart-ish approach? What if the user could simply do like this:

  • Spot a product
  • Click “Buy Now”
  • Pay
Continue reading “How to Optimize Your WooCommerce Store for Single Product/Item Checkout”

How to Add JavaScript to Contact Form 7 events programmatically

Contact Form 7 is probably the most used plugin considering that WordPress official stats rank it 2nd after Akismet which comes bundled with WordPress.

I myself use it a lot, and I had the chance to extend it in different ways depending on my current client needs. The last challenge I had was to add code that runs when the on_sent_ok event is triggered, my client wanted me to add the additional code inside the plugin, so that people won’t be able to remove that code unless they deactivate the plugin.

long story short this is how to do it: Continue reading “How to Add JavaScript to Contact Form 7 events programmatically”

Arabic translation files for WordPress

Wondering why some of the string in the theme or plugin you just translated aren’t found in the .po file or have weird plural form?

This happens a lot because many translators don’t use the right configurations. So besides the search path in Poedit, make sure you have the right configuration for plural forms and keywords list which should be as the following. Continue reading “Arabic translation files for WordPress”

Remove Fields [WP Plugin]

The WordPress plugin Remove Fields main purpose is to help you get more comments to your blog by removing the website field from the comment form, and trust me,  it works, the reason is that a lot of people think that the website field is mandatory, when they see it they will refrain from posting a comment.

What does it do

The most important: It removes the website field from the comment form, which is totally useless in many situations (cooking blog, news website or any other type of websites)

Bonus: The plugin will also get rid of some totally useless fields: AIM, Yahoo IM, Jabber / Google Talk and the Bio section.

After installing the plugin in a client website, the results were amazing, more comments, more interaction with your audience.

Try the plugin now

Install the plugin, rate it and fill free to ask for any feauture you think is missing (like an configuration page).

Add or Remove a word from Firefox dictionary

Lappy, touchpad, plugin, WordPress, vlog… and many other words are not (yet) recognized by Firefox, each time you use any of them Firefox will underline them in red, it would be better not to be bothered by these lines every time you write a “common” word which is not listed in the dictionary.

Add a Word to Firefox dictionary:

Right click on the word and click “Add to Dictionary” or press “o”.

Remove a Word from Firefox dictionary:

Firefox profile directory

It happens sometimes -specially when using a lappy touchpad, that you add by mistake  misspelled word to your Firefox personal dictionary, this how to remove them:

  1. Locate the file persdict.dat (this manipulation is OS independent):
    • At the top of a Firefox window, on the menu bar, click Help> Troubleshooting Information, if the menu bar is hidden press the alt key once to reveal it.
    • A new page will open, click on the button that says Open Containing Folder, this opens the Profile Directory, the button is located under Application Basics
    • Find the file persdict.dat
  2. Close Firefox, otherwise your changes in step 3 will be lost
  3. Open the file persdict.dat on a text editor, you will see that each word you added to the dictionary  constitutes a line in persdict.dat, remove unwanted lines and save… that’s it

WordPress page navigation without using a plugin

wp page navigation
Here is a small… yes, a small function for displaying a paged navigation in your WordPress powered blog without using any plugin.

The function is self-explaining, it accepts one optional parameter, the number of links to show without counting the previous and next buttons.

It accepts your language

The first, previous, next and last buttons text can be set to anything you want from within the function, you probably don’t want to change the presets, the arrows work just fine and don’t need any translation, but it you want to put something else and if you are making a template that is meant for distribution, I advise that you use the __() function, example:

$first_txt = __('First', 'theme_textdomain');
$previous_txt = __('Previous', 'theme_textdomain');
$last_txt = __('Last', 'theme_textdomain');
$next_txt = __('Next', 'theme_textdomain');

The function

This is the function:

 * get_paged_navigation displays a paged navigation
 * @param int $number_of_pages_to_show
 * @author Nabil Kadimi
 * @link
function get_paged_navigation($number_of_pages_to_show = 10){
	$current_page_number = (int) $GLOBALS['paged'];
	$number_of_pages = (int) $GLOBALS['wp_query']->max_num_pages;
	$first_txt = '«';
	$previous_txt = '‹';
	$next_txt = '›';
	$last_txt = '»';
	if($number_of_pages < 2)
		return true;
		$current_page_number = 1;

	$last_head_page_number = ceil($number_of_pages_to_show/2);
	$firt_tail_page_number = $number_of_pages - floor($number_of_pages_to_show/2);

	if($current_page_number = $firt_tail_page_number)
		$page_first_shown = $number_of_pages - $number_of_pages_to_show + 1;
		$page_first_shown = $current_page_number - ceil($number_of_pages_to_show/2) + 1;

	// First arrows
	if($page_first_shown != 1){
		echo '', $first_txt, ' ';
		echo get_previous_posts_link($previous_txt), ' ';
	// Linked page numbers
	for($i=0; $i < $number_of_pages_to_show && $i<$number_of_pages; $i++)
		echo '', $page_first_shown + $i, ' ';
	// Last arrows
	if($page_first_shown + $number_of_pages_to_show < $number_of_pages + 1){
		echo get_next_posts_link($next_txt), ' ';
		echo '', $last_txt, ' ';



With formatting

One more thing, if the pagination will have any formatting surrounding it, you can have a conditional statement so that the formatting doesn’t appear if the pagination is not needed (there is only 1 page), here is an example:

if($GLOBALS['wp_query']->max_num_pages > 1){
	echo '';

WordPress LTR/RTL


I found your website on a WordPress forum. Currently I am rebuilding a website in wordpress that is in English and Farsi. I am using the Qtranslate and a theme called suffusion which supports RTL. The theme does come a rtl.css which moves everything to the right which is great. The problem I am having is switching from my LTR Style Sheet to RTL stylesheet when the language is switched. If you could be of any assistance on this it would be greatly appreciated.

Thank You – Chris

Continue reading “WordPress LTR/RTL”

Detect WordPress version

How can I detect the current WordPress version?

Log in to your admin Dashboard and scroll to the bottom of the page, you’ll find your version number on the rightmost spot of the footer.

WordPress version

Or you can view the source of one of the pages of your blog and look for the meta generator tag:

<meta name="generator" content="WordPress 2.9.1" />

WordPress upgrade error (Allowed memory size of 33554432 bytes exhausted)

The problem

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2516315 bytes) in /home/mydomain/public_html/blog/wp-includes/http.php on line 1370

This can happen at any line and with any file, not only http.php at line 1370!


Don’t worry if you get this error, there is nothing wrong with your server or hosting plan etc. Whenever a new version of WordPress is released, new features are added, thus more calculations, so logically more memory is needed.
In older versions of WordPress (before 2.7… I think), the memory limit was set to 32M, if you are upgrading WordPress, you will probably get that error, you will have to edit the wp-settings.php file and set (I should say change) the constant WP_MEMORY_LIMIT value to 64M, giving PHP more memory to play with.

The solution

  • Open the remote file wp-settings.php file located on the base directory where you installed your WP blog
  • find this code (probably at line 13)

    define('WP_MEMORY_LIMIT', '32M');

  • Replace with

    define('WP_MEMORY_LIMIT', '64M');

  • Run the upgrade process again
  • Enjoy your updated WP blog

How can I set a WordPress page as my blog homepage

This can be done with a few clicks from your WordPress blog control panel.

So first login to your control panel, then

  • under the Settings menu choose Reading,
  • after the page finishes loading, choose A static page (select below) for the option Front page displays,
  • then on the first drop-down list  that follows choose the page you want to set as your blog homepage
  • save!.. you don’t wanna forget that one!

You Reading settings should look as follows (in this example, the page title is “The company” ):
WP homepage options