Life runs on code

WordPress

Enable Category/Tag support for WordPress Media files

Enable Category/Tag support for WordPress Media files

To enable category/tag support on WordPress Media, You have to register taxonomy for Media(attachment) by adding following code in theme function.php or in plugin file register_taxonomy( ‘media-category’, ‘attachment’, $args ); Note : This will work with WordPress 3.5 or higher.

Check if session is started or not in php

Check if session is started or not in php

To avoid Cannot send session cookie – headers already sent warning which is caused by calling the session_start()function without checking if the session is already started or not. You can find following warning in error log file : Warning: session_start() [function.session-start]: Cannot send session cookie […]

Generic autoloader for classes named in WordPress coding style

Generic autoloader for classes named in WordPress coding style

if ( ! class_exists( ‘RT_WP_Autoload’ ) ){ /** * Generic autoloader for classes named in WordPress coding style. */ class RT_WP_Autoload { /** * @var string Current directory absolute path */ public $dir; /** * @param string $dir optional, default value is current */ function […]

Add admin to glotpress

Add admin to glotpress

Following is the script to add admin to glotpress php scripts/add-admin.php user-name Before run script, check you have configured database properly.

register_taxonomy reserved terms

register_taxonomy reserved terms

There are some reserved word for register taxonomy. If you are passing the term through the $_GET or $_POST array. Doing so can cause WordPress to respond with a 404 error without any other hint or explanation. Following is the code snippet to check reserved […]

PHP CodeSniffer – Coding standards

PHP CodeSniffer – Coding standards

PHP CodeSniffer scan PHP, JavaScript and CSS files and detects violations of a defined set of coding standards. To install phpcs on ubuntu pear install PHP_CodeSniffer To list all installed coding standards phpcs -i I found great article on rtCamp site. you can read it […]

Debug WordPress, BuddyPress, WooCommerce javascript

Debug WordPress, BuddyPress, WooCommerce javascript

By default in production mode WordPress, BuddyPress and WooCommerce use minified version of css and javascript. If you are developer and want to debug any core(WordPress) and plugins(BuddyPress and WooCommerce) script or css file then just add following line in your wp-config.php file. define(‘SCRIPT_DEBUG’, true);

Check if it is WooCommerce Page

Check if it is WooCommerce Page

Default WooCommerce function is_woocommerce  return true for only that pages which use WooCommerce templates. Cart, Checkout,My Account … etc page are standard pages with shortcodes so that are not checked by that function. is_realy_woocommerce_page is wrapper of is_woocommerce function and also check if the page is […]

Fix for WordPress SEO (by Yoast) bbPress breadcrumbs issue

Fix for WordPress SEO (by Yoast) bbPress breadcrumbs issue

By default wordpree-seo plugin disable bbPress default breadcrumbs. When i open any topic page, I expected the plugin to do this: Home > Forums > Parent Forum > Child Forum >Topic Instead it did this: Home > Topics > Child Forum > Topic It gives […]