Created
December 12, 2016 05:13
-
-
Save mzalewski/4038b5d350a192624de8d2e01be563eb to your computer and use it in GitHub Desktop.
Returner helper class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('the_title', Returner::v("Test")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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