get_header_image() returns null

While working on a theme in wordpress 3.4.2, I realised that wordpress function get_header_image() returns null in a ‘mu-plugins’ plugin even though in the theme’s functions.php file I’ve set a ‘default-image’ like this: add_theme_support( ‘custom-header’, array( ‘default-image’ => get_template_directory_uri() . ‘/subdir/default-header-image.jpg’ ) ); In the theme template file header.php, I’ve called get_header_image(), and it returns … Read more

WordPress Tinymce Dialogs

If you are trying to implement tinymce for your theme options page or plugins and the Insert/edit link doesn’t pop up the dialog after the button is clicked, try this: add_action( ‘admin_print_footer_scripts’, ‘wp_tiny_mce_preload_dialogs’, 30 ); add_action( ‘tiny_mce_preload_dialogs’, ‘wp_link_dialog’, 30 ); This worked for me as of version 3.1.3.

Converting HTML entities to characters

I was trying to use WordPress post titles as email subject headers in such a way: $subject = get_the_title(); wp_mail( $to, $subject, $message); However this became a problem when the post title included smart quotes, em-dash, ellipsis and the likes of them. My email subject ended up looking like this: Hey – This is my Post’s Title where … Read more

Responsive / Adaptive CSS

Neat way to load required css based on device screen width, instead of using media queries or loading all css: Nathan Smith shows how at adapt.960.gs.

Using a proxy file to load content from external url

/* proxy.php */ <?php echo file_get_contents($_GET[‘url’]);?> then, assuming that you place proxy.php in the same directory of the html page: $(“#content”).load(‘proxy.php?url=http://example.com’);

Extend WordPress Login Expiration

The default login session cookie is 48 hours. Although it’s usually enough for most users, it can be frustratingly short for developers and administrators. Here’s something useful for those who do not want the hassle of logging in now and then. Add this to your theme’s functions.php , or create a php file and load it … Read more

Upgrading MySQL databases on MySQL 5.5

These are steps I went through to upgrade my databases after installing MySQL 5.5 from 5.1 on windows. Presuming that c:\mysql is the installation path of MySQL on windows, at command prompt: C:\> cd c:\mysql C:\MYSQL> bin\mysql_upgrade -p Enter MySQL server password when it prompts: Enter password: That’s it.

Bookmarks, Tabs and Sessions

Update: This idea wouldn’t work well for now because I realised that at startup, Firefox still tries to load all tabs, and even those hidden in Panorama. I’ve been using Firefox 4 for the past week, and the experience has been great so far. One thing I realised about the tabs is that it seems … Read more

PHP Dynamic Variables

This is otherwise known as “Variable variables”. Let’s begin. Basically in PHP, we assign value to a variable like this: $var = “word”; If we want a variable whose name is the value of the $var variable, we do so like this: $$var = “press”; // $word = “press” PHP parses $$var by first de-referencing … Read more

WordPress 3.1 and setup_postdata

After upgrading one of my websites to WordPress to version 3.1, the loops that contained setup_postdata() created a mess. After some testing, I realised that setup_postdata() will only return the correct data if the argument passed is $post, i.e. setup_postdata($post). I had used setup_postdata( $ancestor ) instead and it created a mess after the upgrade. … Read more