Extensions Loader

The Redux Extension Loader is nothing more than a simple script to include your extensions, but only make them available to your custom opt_name. The code is really strait forward, you can see it below:

if(!function_exists('redux_register_custom_extension_loader')) :
	function redux_register_custom_extension_loader($ReduxFramework) {
		$path = dirname( __FILE__ ) . '/extensions/';
		$folders = scandir( $path, 1 );		   
		foreach($folders as $folder) {
			if ($folder === '.' or $folder === '..' or !is_dir($path . $folder) ) {
				continue;	
			} 
			$extension_class = 'ReduxFramework_Extension_' . $folder;
			if( !class_exists( $extension_class ) ) {
				// In case you wanted override your override, hah.
				$class_file = $path . $folder . '/extension_' . $folder . '.php';
				$class_file = apply_filters( 'redux/extension/'.$ReduxFramework->args['opt_name'].'/'.$folder, $class_file );
				if( $class_file ) {
					require_once( $class_file );
					$extension = new $extension_class( $ReduxFramework );
				}
			}
		}
	}
	// Modify {$redux_opt_name} to match your opt_name
	add_action("redux/extensions/{$redux_opt_name}/before", 'redux_register_custom_extension_loader', 0);
endif;

Simply update the {$redux_opt_name} to match your variable and away you go.

 A Few Gotchas

  • Do NOT put your extensions in ~/ReduxCore/extensions or any plugin could override your code.
  • Load the extension loader BEFORE you create your ReduxFramework instance. This has to do with WordPress hooks.

Need more help? Download the Example Loader

Download the Redux Extensions Loader