Categories
Coupons and Promo Codes Hosting Tips & Deals Kavoir & Whatever

KnownHost Coupon Code (75% and 10% Off) and My New Office

I’m having Kavoir moved to Knownhost and now that I have 2 different VPS packages with them, I’m qualified to have an VIP coupon to spread out for 10% off any hosting package purchased with it. It’s one of the best managed VPS hosts around if you search for their reviews on WHT. I’d highly recommend the VS-2 package that is their most cost-effective plan.

KnownHost.com – 75% Off First Month + 10% Off Lifetime

Anyway, if you do make up your mind to sign up with them, go ahead and use this coupon code to claim the 75% off first month and then 10% off lifetime discount:

KnownHost: 75% Off First Month + 10% Off Lifetime
KHBESTUPTIME
Click To Open/Copy

Other than this

I just moved to my new office with a bigger, compound space on 2 floors. Pictured here is the first floor which will serve as a salon for people who are interested in Internet marketing and online businesses. We will talk here about trends and potential opportunities and collaborate on some of them. The second floor will be the actual place where my employees work which is still being decorated and for now is only equipped with a 4-men working unit with 4 DELL Vostro All-in-One computers.

1

Eiffel Eames style plastic armchairs, you can find similar items on Amazon at here and here as well. I love green and black, with a modern tone.

2

Quite spacious, until a 3.9m sofa I ordered comes in. I’m planning to get a bigger library unit than the bookshelf to accommodate more books from Amazon.

3

How does the curtain go with the room theme?

4

Some books I bought on Amazon.

Here are 2 updated pictures of the office after the sofa has shipped in.

Photos taken by the built-in camera of Nokia E71. Not bad for a grandpa phone, eh..

In case you would travel to Xi’an, China, drop me a comment or message and I’ll be very glad to be your host! Winking smile

Categories
WordPress How To

WordPress: Programmatically Add Items to a Menu (Dynamically)

Menus are created and edited from in the WordPress backend and then called in frontend theme to be displayed by the wp_nav_menu() function. On some occasions, we may want to programmatically add one or two menu items to a menu because those menu items change frequently and it would be a chore to have to add / update them in the backend every time any of changes occur.

So how to programmatically add menu items to a WP menu on the fly?

For instance, what we have now in our theme as the top menu:

<ul id="main-nav" class="nav fl">
	<?php
	
	wp_nav_menu(array(
		'depth' => 6, 
		'sort_column' => 'menu_order', 
		'container' => 'ul', 
		'menu_id' => 'main-nav', 
		'menu_class' => 'nav fl', 
		'theme_location' => 'primary-menu', 
		'items_wrap' => '%3$s'
	));
	
	?>
</ul>

Firstly, we need to get the HTML returned by wp_nav_menu() by setting the parameter ‘echo’ => false. This way, we can get the menu HTML as a PHP variable and then manipulate it however we want. What I want to do is to add some sub menu items to the “Shop” item:

<ul id="main-nav" class="nav fl">
	<?php
	
	$my_wp_nav_menu = wp_nav_menu(array(
		'depth' => 6, 
		'sort_column' => 'menu_order', 
		'container' => 'ul', 
		'menu_id' => 'main-nav', 
		'menu_class' => 'nav fl', 
		'theme_location' => 'primary-menu', 
		'items_wrap' => '%3$s', 
		'echo' => false
	));
	
	$my_wp_nav_menu = str_replace(
		'>Shop</a></li>', 
		'>Shop</a><ul class="sub-menu">'.$my_sub_items_html.'</ul></li>', 
		$my_wp_nav_menu
	);
	
	echo $my_wp_nav_menu;
	
	?>
</ul>

The key is to insert a sub menu in there. In this case, I used the str_replace() function to do this. Make sure you use appropriate classes for <ul></ul> and <li></li> or they won’t be rendered as a sub menu.

$my_sub_items_html contains the sub menu items such as this:

<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="/product-category/bags/">Bags</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="/product-category/accessories/">Accessories</a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page"><a href="/product-category/toys/">Toys</a></li>

These can be dynamically generated from one of the taxonomies of your WordPress blog or you can specify your own.

Categories
WordPress How To

Customize WordPress Login Header and Link, Upgrade-proof without Plugin

The default image header and link on the login / register page of WordPress is a WordPress one, apparently, but when you are enabling registration / login to general users, you would want to use your own logo and website URL as the header rather than the default -  so people don’t get confused and freak out!

It’s amazing how WordPress has made such simple customizations even simpler by the introduction of hooks. Just insert the following snippet in your theme’s functions.php:

add_action('login_head', 'my_custom_login_logo');
function my_custom_login_logo() {
    echo '<style type="text/css">
        h1 a { background-image:url('.dirname(get_bloginfo('stylesheet_url')).'/my_custom_login_logo.png) !important; }
    </style>';
}

add_filter('login_headerurl', 'my_custom_login_link');
function my_custom_login_logo(){
    return ('/'); // put here your website URL such as http://www.example.com/ or simply /
}

Just provide your own logo and upload it to your theme directory as my_custom_login_logo.png. You can also use get_bloginfo(‘template_directory’) for theme path but that would return the parent theme path if you have a child theme. Sensibly, we would put all customizations in the child theme, so dirname(get_bloginfo(‘stylesheet_url’)) is probably a better approach.

Without editing the core files, this solution is upgrade-proof and you don’t have to install any plugin.

Categories
Computer & Internet Literacy Internet Tools

Enable Firefox Spell Checker for Single-line Text Input

Firefox has come with a tremendously useful feature that is the spell checking. However the problem is, by default, it only checks the spelling of text in <textarea></textarea> the block text input. How to make it also check the spelling of <input type=”text” /> so that we can be worry-free of misspelled words in single-line input text boxes as well such as when you are entering article titles, product names, etc.?

There is a very simple way to do this. Just fire up your Firefox, type in the address bar and enter:

about:config

And then filter by:

layout.spellcheckDefault

So that you would see a configuration line like this:

firefox spell checker settings

Double click on the Value and change it from 1 to 2. That’s it.

You don’t even have to restart Firefox and it will start inspecting all single-line input text boxes for wrong spellings from now on.

Categories
Linux Server Administration Tips

Cannot use ctrl-c. How to stop tail -f, etc?

When I ssh into my Debian Squeeze server and start up tail -f to watch a log file or anything else which uses ctrl-c to exit/stop, ctrl-c does not work. It prints the ^C character on screen and just keeps right on going.

Is there a setting somewhere that can be tweaked or maybe a different key combo that needs pressed?

Search results suggest that it’s a pretty common problem to Debian and that tinkering with the getty settings in /etc/inittab can fix it, but I’m hesitant to mess around in there too much. I may just take a snapshot and then see what happens.

Definitely an inittab thing, in case anyone else runs into this.
This line used to be at the top of the getty stuff

Code:

8:2345:respawn:/sbin/getty 38400 hvc0

I just moved it to the bottom and now ctrl-c works when connected using ssh.

Code:

 1:2345:respawn:/sbin/getty 38400 tty1
 2:23:respawn:/sbin/getty 38400 tty2
 3:23:respawn:/sbin/getty 38400 tty3
 4:23:respawn:/sbin/getty 38400 tty4
 5:23:respawn:/sbin/getty 38400 tty5
 6:23:respawn:/sbin/getty 38400 tty6
 8:2345:respawn:/sbin/getty 38400 hvc0