Assigning Google Adsense code to a PHP variable doesn’t work the way you would expect it to. I thought just deleting the newline characters and extra spaces from the adsense code and then assigning the resulting text to a variable should work. However it does not, and I’m not sure why. However what does work is shown below.

<?php
$googleadsensecode = '
<script type="text/javascript">
google_ad_client = "pub-123456789";
google_ad_slot = "123456";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
echo $googleadsensecode;
?>

The following example does not work.

<?php
$googleadsensecode = '<script type="text/javascript"> <!-- google_ad_client = "ca-pub-123456789"; google_ad_slot = "123456"; google_ad_width = 300; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>';
echo $googleadsensecode
?>

I was bored with the default breadcrumbs that come with Theme Hybrid. Wanted something new. I looked up some tutorials for nice looking breadcrumbs. Found this one which I liked quite a lot and decided to implement it for Humbug. Usually, things are very simple with Theme Hybrid, but this one was slightly ugly. Here’s the code that I used:Continue reading

I have been playing around with Symphony CMS the past one week (I’m kinda bored of WordPress). I use Dreamhost for all my hosting needs. Dreamhost is also one of the recommended hosts for Symphony, but has a low 3 star rating. I soon figured out why – one of the core symphony features called ensemble doesn’t work on Dreamhost because PHP on Dreamhost isn’t compiled with the ZipArchive class. Continue reading

get_allowed_mime_types

About a week back, I was writing a post on this blog and wanted to attach a shell script using WordPress Download Monitor. However when I tried to attach the script file (.sh extension), it gave me “No File Selected” error after trying to upload the file. Tried again, and the same result. I uploaded a zipped version of the file and that uploaded fine. So I figured, it must be an issue with the mime type/file extension. Found this link which reports the same issue and the solution.

Here’s how you fix this.

1. Log on to your server either through SSH or FTP.

2. Change directory to wp-includes directory in the root of your wordpress installation. For Eg (in my case)

cd ~/humbug.in/wp-includes/

3. Open the functions.php file with your favourite editor.

vi functions.php

4. Search for the get_allowed_mime_types function. At the time of writing, its at line 2275.

5. Go to the bottom of the function (Shift + ] in vim) and add a new entry at the end of all the mime type entries for the desired mime type. At the time of writing, all the openoffice formats are the bottom most entries.

// openoffice formats
 'odt' => 'application/vnd.oasis.opendocument.text',
 'odp' => 'application/vnd.oasis.opendocument.presentation',
 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
 'odg' => 'application/vnd.oasis.opendocument.graphics',
 'odc' => 'application/vnd.oasis.opendocument.chart',
 'odb' => 'application/vnd.oasis.opendocument.database',
 'odf' => 'application/vnd.oasis.opendocument.formula',

6.  See the sample screenshot below for the new ‘sh’ mime type entry. Check this link for a list of mime types.