Debugging in WordPress

wp-config.php

Any code developed for the first time is not 100% bug free. While working on a Wordpress based website or any other technology website it becomes easy to fix the bugs/issues if they are pointed out by the system.

“wp-config.php”  file located at the root of wordpress folder provides settings that enable the “Debugging” mode in wordpress.

Continue reading »

Disable Post Revisions in WordPress

revisions

Wordpress provides a very good feature of maintaining post/page revisions. By default this feature is enabled so wordpress will save copies of each edit made to a post or page; this provides us a provision to revert to a previous version of that post/page.

While you website is in development mode, you may want to disable the “Post Revisions” feature. Also website owners with limited database space may want to disable this feature or limit the number revisions saved.

Lets see the related settings to be made in the configuration file “wp-config.php” located in your WordPress root directory.

Continue reading »

Redirect your website users to your preferred URL, either WITH or WITHOUT the ‘www.’ prefix

www

If your website can be accessed with and without www then its considered having duplicate pages. If you have ever integrated the “facebook like” button on your website pages, try accessing the page with www and without www; you will notice different like counts displayed on the pages.

To prevent these duplicate pages on your website, you can redirect non-WWW traffic to WWW or vice-versa using mod_rewrite in your .htaccess file.

Continue reading »

Force Files to Download Instead of Showing Up in the Browser

curl vs wget

Sometimes you may have noticed that when you click on a download link, the file shows up in one browser while in some other browser it gets downloaded. Internet Explorer will usually try to show Microsoft Word files (doc and docx) in the browser, while most other browsers will download it.

If the browser supports a file it shows up the file else it downloads the file. Image files like png, gif, jpg almost always show in the browser. Archive files like zip, tar, and gzip almost are always downloaded.

Continue reading »

Magento: Get Base Url, Skin Url, Js Url, Media Url, Store Url

Retrieving URLs in Magento

1. Get Base URL

<?php
$base_url = Mage::getBaseUrl();
?>

2. Get Current URL

<?php
$current_url = Mage::helper('core/url')->getCurrentUrl();
?>

3. Get Home URL

<?php
$home_url = Mage::helper('core/url')->getHomeUrl();
?>

4. Get Store URL

<?php
$store_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
?>

5. Get Media URL

<?php
$media_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
?>

Continue reading »

Modifying the response in Magento before its displayed on browser

Magento uses a response object to send all output. All output is added to this object, and then its sendResponse method is called.  If you need to modifying the response in Magento before its displayed on browser then you can listen to the event “http_response_send_before” and modify the output in the observer method.

Continue reading »

Magento – AJAX "Headers already sent" error solved

While working with AJAX in Magento many of you might have received the following error like I did:

2013-05-02T10:25:15+00:00 DEBUG (7): HEADERS ALREADY SENT:
[0] /var/www/html/ecomm/app/code/core/Mage/Core/Controller/Response/Http.php:44
[1] /var/www/html/ecomm/lib/Zend/Controller/Response/Abstract.php:727
[2] /var/www/html/ecomm/app/code/core/Mage/Core/Controller/Response/Http.php:75
[3] /var/www/html/ecomm/app/code/core/Mage/Core/Controller/Varien/Front.php:188
[4] /var/www/html/ecomm/app/code/core/Mage/Core/Model/App.php:304
[5] /var/www/html/ecomm/app/Mage.php:599
[6] /var/www/html/ecomm/index.php:104

Continue reading »

SEO Ultimate version 7.6.1 syntax error on installation

I downloaded SEO Utlimate Version 7.6.1 [http://wordpress.org/extend/plugins/seo-ultimate/] wordpress plugin for my blog site. I unzipped the downloaded file and uploaded the extracted folder to /wp-content/plugins/. When I activated the plugin from admin I got the following error:

Parse error: syntax error, unexpected T_IF in /home/xxx/public_html/wp-content/plugins/seo-ultimate/modules/author-links/author-links.php on line 1

Continue reading »

Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with Zend_Pdf_FileParserDataSource::__construct()

In one of our Magento projects, on development environment everything was working fine but when the site was live “Invoice” print in magento admin [Admin >> Sales >> Orders >> Invoice tab >> Open Invoice >> Click print button] was giving Fatal Error.

We though that we might have missed some file when moving to live site but ultimately we found that code base was same.

Continue reading »

Overriding Magento admin theme files

We create a new theme and assign it in the Magento admin to override the frontend theme. What if you need to override the admin theme file? Edit the default magento file? No, its not a good practise.

Continue reading »

Back to top