| 1 |
<?php |
| 2 |
/** |
| 3 |
* Abstract Shortcode Class |
| 4 |
* |
| 5 |
* Use with add_shortcode('leaflet-map', array('Leaflet_Shortcode', 'shortcode')) |
| 6 |
* extend and manipulate __construct |
| 7 |
* |
| 8 |
* @var array $atts |
| 9 |
* @var string $content |
| 10 |
*/ |
| 11 |
abstract class Leaflet_Shortcode { |
| 12 |
protected $LM; |
| 13 |
|
| 14 |
/** |
| 15 |
* Generate HTML from the shortcode |
| 16 |
* Maybe won't always be required |
| 17 |
* @since 2.8.2 |
| 18 |
* @var array $atts |
| 19 |
* @var string $content |
| 20 |
* @return HTML |
| 21 |
*/ |
| 22 |
abstract protected function getHTML($atts='', $content=null); |
| 23 |
|
| 24 |
public static function getClass () { |
| 25 |
return function_exists( 'get_called_class' ) ? get_called_class() : __CLASS__; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Instantiate class and get HTML for shortcode |
| 30 |
* @var array $atts |
| 31 |
* @var string $content |
| 32 |
*/ |
| 33 |
public static function shortcode ($atts, $content = null) { |
| 34 |
$class = self::getClass(); |
| 35 |
$instance = new $class($atts, $content); |
| 36 |
return $instance->getHTML($atts, $content); |
| 37 |
} |
| 38 |
|
| 39 |
protected function __construct() { |
| 40 |
$this->LM = Leaflet_Map::init(); |
| 41 |
} |
| 42 |
} |