[wp-hackers] WP_CONTENT_DIR and PLUGINDIR

Stephen Rider wp-hackers at striderweb.com
Tue Sep 9 13:25:03 GMT 2008


On Sep 8, 2008, at 2:14 PM, Frank Bueltge wrote:

> // Pre-2.6 compatibility
> if ( !defined('WP_CONTENT_URL') )
> 	define( 'WP_CONTENT_URL', get_option('url') . '/wp-content');
> if ( !defined('WP_CONTENT_DIR') )
> 	define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
> if ( !defined('WP_PLUGIN_URL') )
> 	define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
>
> Thats my way in all plugins, i checl for the constants

Cool, but methinks this works a touch better.  You're forgetting  
WP_SITEURL, and I added WP_PLUGIN_DIR for completeness:

// Pre-2.6 compatibility
if ( ! defined( 'WP_CONTENT_URL' ) ) {
	if ( defined( 'WP_SITEURL' ) )
		define( 'WP_CONTENT_URL', WP_SITEURL . '/wp-content' );
	else
		define( 'WP_CONTENT_URL', get_option( 'url' ) . '/wp-content' );
}
if ( ! defined( 'WP_CONTENT_DIR' ) )
	define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
if ( ! defined( 'WP_PLUGIN_URL' ) )
	define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
if ( ! defined( 'WP_PLUGIN_DIR' ) )
	define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );


The answer to the ambiguity of PLUGINDIR is of course simply not to  
use it. :)

Stephen


-- 
Stephen Rider
<http://striderweb.com/>



More information about the wp-hackers mailing list