[wp-hackers] Plugin main file name

Stephen Rider wp-hackers at striderweb.com
Tue Aug 26 04:20:49 GMT 2008


On Aug 25, 2008, at 11:06 PM, Stephen Rider wrote:

> I've worked out a system for versioning common plugin code.  Each  
> plugin has its own copy of the common code file.  System checks them  
> all, finds the highest version, and loads that file, then loads the  
> plugins that use it.

Here's the interesting part of the strider_core.php file:

<?php

if( ! function_exists('load_strider_core') && ! $strider_core_version  
&& ! class_exists( 'strider_core' )  ) {
class strider_core {
	// bunch of shared code
} // end class
} // end if

if( ! function_exists('load_strider_core') ) {

	function load_strider_core() {
		global $strider_core_plugins;  // array holds a list of plugin class  
files that have _not_ been loaded yet
		global $strider_core_version;

		$best_file = $strider_core_version[0];
		foreach( $strider_core_version as $this_core ) {
			$best_file = version_compare( $best_file['version'],  
$this_core['version'] ) == 1 ? $best_file : $this_core;
		}

		$strider_core_version = null;
		require( $best_file['file'] );

		foreach( $strider_core_plugins as $plugin_file ) {
			include_once( $plugin_file );
		}
	}

	add_action( 'plugins_loaded', 'load_strider_core' );

} // end if

$strider_core_version[] = array(
	'version' => '0.1',
	'date' => 20080825,
	'file' => __FILE__ );

?>




More information about the wp-hackers mailing list