-
-
Save brentini/af1622932d20264b2bec23016126bb75 to your computer and use it in GitHub Desktop.
WordPress Generic Object #wordpress
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
| <?php | |
| /** | |
| * Registers all ShortCode_* methods | |
| */ | |
| static public function Register_ShortCodes() { | |
| // part of string to search for | |
| $keyword = 'ShortCode_'; | |
| // loop all class methods | |
| foreach( get_class_methods(__CLASS__) as $method ) { | |
| // test method name for keyword | |
| if( substr($method, 0, strlen($keyword)) == $keyword ) { | |
| // this is a shortcode method! register it | |
| $shortcode = str_replace( $keyword, '', $method ); | |
| add_shortcode( $shortcode, array(__CLASS__, $method) ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment