Skip to content

Instantly share code, notes, and snippets.

@scribu
Created August 10, 2012 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scribu/5ee61a934a8c38fe8e2b to your computer and use it in GitHub Desktop.
Save scribu/5ee61a934a8c38fe8e2b to your computer and use it in GitHub Desktop.
WP_Image_Editor choosing implementation
<?php
class WP_Image_Editor {
final public static function get_instance( $path ) {
$implementation = apply_filters( 'image_editor_class', self::choose_implementation(), $path );
if ( $implementation )
return new $implementation( $path );
return false;
}
// Chooses the best available image handling library available
private static function choose_implementation() {
static $implementation;
if ( null === $implementation ) {
// actual logic for setting $implementation goes here
...
}
return $implementation;
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment