Added add_shortcodes function
Showing
1 changed file
with
12 additions
and
0 deletions
| ... | @@ -45,4 +45,16 @@ function add_actions($class) { | ... | @@ -45,4 +45,16 @@ function add_actions($class) { |
| 45 | add_action($action->name, Array($class, $action->name)); | 45 | add_action($action->name, Array($class, $action->name)); |
| 46 | } | 46 | } |
| 47 | } | 47 | } |
| 48 | |||
| 49 | function add_shortcodes($class) { | ||
| 50 | if (!class_exists($class)) { | ||
| 51 | throw new Exception("$class does not exist"); | ||
| 52 | } | ||
| 53 | |||
| 54 | $ref = new ReflectionClass($class); | ||
| 55 | $methods = $ref->getMethods(ReflectionMethod::IS_STATIC); | ||
| 56 | foreach ($methods as $method) { | ||
| 57 | add_shortcode($method->name, Array($class, $method->name)); | ||
| 58 | } | ||
| 59 | } | ||
| 48 | ?> | 60 | ?> | ... | ... |
-
Please register or sign in to post a comment