Tag Archives: Wordpress

New Relic – Enable Drupal module monitoring

New Relic supports the following list of PHP frameworks.

  • Drupal 6 and 7
  • WordPress
  • CakePHP 1.2, 1.3 and 2.*
  • CodeIgniter 2
  • QDrupal
  • Joomla 1.5 and 1.6
  • Symfony 1
  • Yii
  • Zend Framework 1
  • Magento 1.5 and 1.6
  • MediaWiki
  • Kohana

If you are monitoring a Drupal website, you will find the module tab on the Application menu.

Continue reading New Relic – Enable Drupal module monitoring

Advertisements

Wordpress – Detect the current language of qTranslate in PHP

We can use the qtrans_getLanguage() to get the current language of a WordPress website.

if (qtrans_getLanguage() == 'en') {
  // english
} elseif (qtrans_getLanguage() == 'zh') {
  // traditional chinese
}

 

Done =)

Reference: How to Get Current Language Code by Using qTranslate Plugin of WordPress

jQuery & Javascript – Capture the Browser or Tab Closed Event

I was working on a WordPress project which i need to clear the PHP session when the browser or browser tab is closed. Although Javascript provides the window.onbeforeunload event but it will be triggered even whenever you leave the website. Finally i got a simple solution from Daniel Melo in StackOverflow. The following code required jQuery and i have included the Google one in the HTML.

In your web root, create the js/check_browser_close.js. Continue reading jQuery & Javascript – Capture the Browser or Tab Closed Event

Wordpress – Enable PHP Session

Add the following code under the top PHP opening tag of wp-config.php.

<?php
  if (!session_id()) {
    session_start();
  }
...

We can now make use of the $_SESSION[] in WordPress. The reason of putting the session_start() in wp-config.php is because this configuration file will not be overwritten during a WordPress update.

Thanks Frank Verhoeven.

Done =)

Reference: Frank Verhoeven – Using Sessions in WordPress

Updated @ 2012-08-02: Please note that their maybe security issue of using the PHP session. For more information, please refer to the following link.
PHP $_SESSION variables