| @@ -1,10 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Abstract Shortcode |
| 4 | 4 | * |
| 5 | - * PHP Version 5.5 | |
| 6 | - * | |
| 7 | 5 | * @category Shortcode |
| 8 | 6 | * @author Benjamin J DeLong <ben@bozdoz.com> |
| 9 | 7 | */ |
| 10 | 8 | |
| @@ -15,8 +13,11 @@ | ||
| 15 | 13 | * extend and manipulate __construct |
| 16 | 14 | */ |
| 17 | 15 | abstract class Leaflet_Shortcode |
| 18 | 16 | { |
| 17 | + /** | |
| 18 | + * @var Leaflet_Map | |
| 19 | + */ | |
| 19 | 20 | protected $LM; |
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * Generate HTML from the shortcode |
| @@ -38,12 +39,12 @@ | ||
| 38 | 39 | |
| 39 | 40 | /** |
| 40 | 41 | * Instantiate class and get HTML for shortcode |
| 41 | 42 | * |
| 42 | - * @param array $atts string|array | |
| 43 | - * @param string $content Optional | |
| 43 | + * @param array|string|null $atts string|array | |
| 44 | + * @param string|null $content Optional | |
| 44 | 45 | * |
| 45 | - * @return string (see above) | |
| 46 | + * @return string HTML | |
| 46 | 47 | */ |
| 47 | 48 | public static function shortcode($atts = '', $content = null) |
| 48 | 49 | { |
| 49 | 50 | $class = self::getClass(); |
| @@ -80,8 +81,25 @@ | ||
| 80 | 81 | } |
| 81 | 82 | } |
| 82 | 83 | |
| 83 | 84 | return $instance->getHTML($atts, $content); |
| 85 | + } | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * Wrap Javascript output with common function and tags | |
| 89 | + * | |
| 90 | + * @param string $script JavaScript | |
| 91 | + * @param string $name string name of function | |
| 92 | + * | |
| 93 | + * @return string JavaScript | |
| 94 | + */ | |
| 95 | + protected function wrap_script($script, $name="") | |
| 96 | + { | |
| 97 | + ob_start(); | |
| 98 | + ?><script> | |
| 99 | +window.WPLeafletMapPlugin = window.WPLeafletMapPlugin || []; | |
| 100 | +window.WPLeafletMapPlugin.push(function <?php echo $name; ?>() {<?php echo $script; ?>});</script><?php | |
| 101 | + return ob_get_clean(); | |
| 84 | 102 | } |
| 85 | 103 | |
| 86 | 104 | /** |
| 87 | 105 | * Create an LM variable for each shortcode class |