Categories
WordPress How To

Customize WordPress Admin Styles from Your Theme Directory

It’s better to style the /wp-admin of WordPress from your theme because it’s portable and upgrade-proof. Keeping all customizations  in ONE place is always a good idea in web development.

How to style WordPress admin backend /wp-admin from your theme?

  1. Add this hook to the functions.php of your theme:
    function customAdmin() {
        ?><link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/wp-admin.css" /><?php
    }
    add_action('admin_head', 'customAdmin');

    Which effectively adds a stylesheet to the header of every /wp-admin page.

  2. Create a text file named wp-admin.css in your theme directory.
  3. Write the customization styles in wp-admin.css.

That’s it. Now you can freely customize the look and appearance of the WordPress admin backend from within wp-admin.css in your theme directory.

Categories
Coupons and Promo Codes Hosting Tips & Deals

Super Cheap Cloud VPS: 1 Core, 1024MB, SSD, Managed – Just $21.25 / Month

Some of my sites such as ConvertHub has grown out of the 512MB box I have had for over 2 years at Linode. It’s been great but as I’m fed up with managing the server myself (I’ll come to that later), I went ahead looking for a solid VPS plan with WHM / cPanel that’s managed for me. After searching for a few weeks, I finally landed my deal with A Small Orange.

See their cloud VPS planner at here: http://asmallorange.com/hosting/cloud/

A Small Orange Double RAM Cloud VPS Sale

What I did was:

  1. Select 1 Core + 1024MB RAM + 15GB Drive (It’s SSD!) + 500GB Bandwidth for $30 / month.
  2. Opt to pay annually so I can get 2 months free. Not that you will get 2 months free, but you will be paying $25 / month instead of $30 / month if you pay annually, working out to be $60 discount over a year from $360 / year to just $300 / year.
  3. Click and use the 15% coupon code:
    ASO15PERCENTOFF
    Click To Open/Copy
    to claim an additional 15% discount off the annual price from $300 to just $255.

That’s it. You get all these awesome stuff for just $255 / year, that’s just $21.25 / month:

  1. 1 Core – Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz
  2. 1024MB RAM
  3. 15GB SSD (Solid-State Drive)
  4. 500GB monthly transfer
  5. WHM / cPanel
  6. 2 Dedicated IPs that are far from each other – NOT in the same C-class! This is a huge benefit for SEO reasons. Another proof that A Small Orange thinks in the customers’ shoes.
  7. Fully managed
  8. Almost instant response to support tickets – I have only been with them for a few days and the support response is well within 30 minutes each time I submit a ticket.
  9. It’s A Small Orange, an established business and brand since 2003. Just search for their reviews.

I challenge you to find a better VPS deal than this cause’ it’s mission impossible. The only downside is that the disk storage will have only about 8GB available for your websites / applications after the system takes 7GB. However, I doubt your websites would need that much unless they have millions of image files or tens of millions of records in the database.

Categories
WordPress How To

Make WordPress Hooked Function to Run Only Once

Consider this hook to add something before your WordPress blog’s sidebar:

function before_siderbar() {
?>
<!-- Something goes here, such as an AdSense links unit -->
<?php
}
add_action( 'get_sidebar', 'before_siderbar' );

It’s usual to add an AdSense links unit there but the problem with some themes is that they run get_sidebar more than once, such as on the sidebar AND in the footer. Consequently, you would end up with multiple AdSense links unit here and there, whereas you only wanted it on the sidebar once.

This could create a TOS problem towards AdSense because unconsciously, you would very probably end up adding more than 3 links unit per page.

To prevent this and only make the hooked WordPress function to run once (even it is called multiple times), use the PHP static variable in functions.

function before_siderbar() {
	static $called = false;
	if (isset($called) && $called) {
		return false;
	}
?>
<!-- Something goes here, such as an AdSense links unit -->
<?php
	$called = true;
}
add_action( 'get_sidebar', 'before_siderbar' );

In the above snippet, the variable $called is kept alive across multiple calls to the before_siderbar() function. After the first successful run of the function, $called would have a value of true and it’s kept so inside the function every time it’s called afterwards. In the 2nd and every call afterwards, $called will always be true and the function returns before outputting the AdSense code.

There you go. Now no matter how many times the before_sidebar() is called, only the first run would output the stuff you put in it.