Skip to content

Instantly share code, notes, and snippets.

@mzalewski
Created December 12, 2016 05:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mzalewski/4038b5d350a192624de8d2e01be563eb to your computer and use it in GitHub Desktop.
Returner helper class
add_filter('the_title', Returner::v("Test"));
class Returner {
private static $returned = array();
private $value;
public function __construct( $value ) {
$this->value = $value;
}
public function result( $arg ) {
return $this->value;
}
public static function v( $value ) {
if ( isset( Returner::$returned[$value] ) ) {
return Returner::$returned[$value];
}
$sc = new Returner( $value );
$returnCallable = array( $sc, 'result' );
Returner::$returned[$value] = $returnCallable;
return $returnCallable;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment