LAMP How To – Open Source At Work

Only Passion Matters

Entries for the ‘Think PHP’ Category

using git ignore

gitignore is helpful when you want to ignore certain files (such as the config files) while working on the files checked out from a git repository. You do not want to commit the config files because other people working on the same repository would also pull your config files which is bad.
Why ignore? because it [...]

parsing html to be xml compliant

htmlentities is not meant for this, use htmlspecialchars instead, ie
htmlspecialchars($var, ENT_NOQUOTES, ‘UTF-8′);
a one liner that can save the day…

Allowing wordpress to host multiple websites

1. download or upgrade to the latest version of wordpress.
2. In wp-config.php, add this line above the “happy blogging” comment

define(‘WP_ALLOW_MULTISITE’, true);
/* That’s all, stop editing! Happy blogging. */

3. Now login and to to admin panel via /wp-admin and go to toos -> network and follow the instructions from there. You will be asked to logout [...]

cannot login to wordpress after allowing multisite

might need to add these lines to wp-config.php as well after doing all the changes after upgrading to multisite.
define(‘ADMIN_COOKIE_PATH’, ‘/’);
define(‘COOKIE_DOMAIN’, ”);
define(‘COOKIEPATH’, ”);
define(‘SITECOOKIEPATH’, ”);

Preventing css or javascript caching

making css or javascript unique is important to bypass any caching mechanism, ie good for checking updates in production environment.
Some good technique involves appending a version number or timestamp after the filename. In wordpress, it is really easy
<link rel=”stylesheet” href=”<?php bloginfo(’stylesheet_url’); ?>?<?php echo filemtime(TEMPLATEPATH.’/style.css’); ?>” type=”text/css” />