Created
March 2, 2017 18:40
-
-
Save 5A5K1A/3c2ce9cd035f24fb9e740f917e20c0ae to your computer and use it in GitHub Desktop.
WordPress Generic Object
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