Wordpress: Disqus plugin hiding content on mobile

If you use the disqus plugin on your wordpress site, you may be surprised to learn that your content is hidden on mobile devices (specifically ipad/iphone). The problem that occurs is that the content is covered by a nice white box that you can’t see through. Thankfully there’s a nice quick fix. In your site’s css rules, simply add the following :- #disqus_thread { clear: both !important; } And mobile users can see your content again!

Magento bug: custom option values not showing in backend

It’s a little bit annoying that such a core feature is just broken in many versions of magento - the headings for the custom options chosen, whilst fully working on the cart; checkout and emails to the customer, only show the heading and no content on the backend order. There are a couple of fixes : in app/code/core/Mage/Adminhtml/Block/Sales/Items/Column/Name.php there is no extending, so you can copy it to app/code/local/Mage/Adminhtml/Block/Sales/Items/Column/Name.php and add the following class method : public function getFormattedOption($value) { $_remainder = ''; $value = Mage::helper('core/string')->truncate($value, 55, '', $_remainder); $result = array( 'value' => nl2br($value), 'remainder' => nl2br($_remainder) ); return $result; } and/or change the admin theme in app/design/adminhtml/default/default/template/sales/items/column/name.phtml around about line 44 from : <?php $_option = $this->getFormattedOption($_option['value']); ?> to <?php if (!is_null($this->getFormattedOption($_option['value']))) { $_option = $this->getFormattedOption($_option['value']); } ?> Then the custom options chosen by customers will happily show in the backend.

Simple PHP Scraping with jQuery Like Selectors using Simple HTML Dom

If you need to do some HTML parsing, scraping etc then you generally have the choice of using the DOM approach to parse the HTML or using regex to pull bits out. I quite like both approaches, there are pros and cons to both so having both options available is the best to ensure you use the right tool for the job on a case by case basis. Recently though I discovered Simple HTML Dom. Read On →

Debugging Output Buffering Being Disabled

If you are confused as to exactly which bit of code is killing your output buffer in PHP then you might love this little trick. Combined with Xdebug it can get you to the root of the problem quickly and easily. The trick involves using the callback function capability of ob_start. Firstly you need to make a callback handler, for example: function ob_callback(){ echo 'wtf'; } Then in your IDE, set a break point on the echo line. Read On →

Xampp 1.8 is out!

A new version of Xampp has been release which includes PHP 5.4! Remember that instantly jumping to the latest version of PHP is not necessarily a good idea as numerous deprecated features may have been removed and others may now be deprecated and cause issues in your applications. Check the PHP 5.4 release announcement for the major changes: http://php.net/releases/5_4_0.php The Xampp 1.8 release also includes numerous other updates including phpMyAdmin, MySQL and many more of the applications bundled with it. Read On →

Xdebug PHP and Command Line Scripts

I had a requirement to use Xdebug to step through a PHP script that is being run on the command line. Oh no I thought, this is bound to be really complicated to figure out because I normally use the web browser and I have never done this before. Pleasant surprise, its actually really easy to do this, all you need to do on the command line is run the following command: export XDEBUG_CONFIG="idekey=netbeans-xdebug" Then get your IDE (PHPStorm for me) listening for Xdebug and then run your PHP file on the command line. Read On →