Added new Short code helper functions
Showing
1 changed file
with
14 additions
and
1 deletions
| ... | @@ -5,7 +5,7 @@ namespace Tz\WordPress\Tools\ShortCodes; | ... | @@ -5,7 +5,7 @@ namespace Tz\WordPress\Tools\ShortCodes; |
| 5 | use Tz\WordPress\Tools; | 5 | use Tz\WordPress\Tools; |
| 6 | 6 | ||
| 7 | use ReflectionClass, ReflectionMethod, ReflectionFunction; | 7 | use ReflectionClass, ReflectionMethod, ReflectionFunction; |
| 8 | use Exception; | 8 | use Exception, Closure; |
| 9 | 9 | ||
| 10 | call_user_func(function() { | 10 | call_user_func(function() { |
| 11 | Tools\add_actions(__NAMESPACE__ . '\Actions'); | 11 | Tools\add_actions(__NAMESPACE__ . '\Actions'); |
| ... | @@ -46,6 +46,19 @@ function getFileContents($file) { | ... | @@ -46,6 +46,19 @@ function getFileContents($file) { |
| 46 | return $parsed_contents; | 46 | return $parsed_contents; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | function buffer(Closure $cb) { | ||
| 50 | ob_start(); | ||
| 51 | $cb(); | ||
| 52 | $contents = ob_get_contents(); | ||
| 53 | ob_end_clean(); | ||
| 54 | |||
| 55 | return $contents; | ||
| 56 | } | ||
| 57 | |||
| 58 | function dump($var) { | ||
| 59 | return '<pre>' . buffer(function() use ($var) { print_r($var); }) . '</pre>'; | ||
| 60 | } | ||
| 61 | |||
| 49 | function registerClass($class) { | 62 | function registerClass($class) { |
| 50 | call_user_func(__NAMESPACE__ . '\add_shortcodes', $class); | 63 | call_user_func(__NAMESPACE__ . '\add_shortcodes', $class); |
| 51 | } | 64 | } | ... | ... |
-
Please register or sign in to post a comment