PluginProbe
Leaflet Map / 2.11.2
Leaflet Map v2.11.2
3.4.7 3.4.6 trunk 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.11.5 2.12.0 2.13.0 2.14.0 2.15.0 2.16.0 2.16.1 2.16.2 2.17.0 2.17.1 2.17.2 2.17.3 2.18.0 2.19.0 2.19.1 All 49 releases
leaflet-map / shortcodes / class.shortcode.php

class.shortcode.php in Leaflet Map 2.11.2, at shortcodes/class.shortcode.php

62 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Abstract Shortcode
4 *
5 * PHP Version 5.5
6 *
7 * @category Shortcode
8 * @author Benjamin J DeLong <ben@bozdoz.com>
9 */
10
11 /**
12 * Abstract Shortcode Class
13 *
14 * Use with add_shortcode('leaflet-map', array ('Leaflet_Shortcode', 'shortcode'))
15 * extend and manipulate __construct
16 */
17 abstract class Leaflet_Shortcode
18 {
19 protected $LM;
20
21 /**
22 * Generate HTML from the shortcode
23 * Maybe won't always be required
24 *
25 * @param array $atts string
26 * @param string $content Optional
27 *
28 * @since 2.8.2
29 *
30 * @return string (typically, return a script tag with Leaflet logic)
31 */
32 abstract protected function getHTML($atts='', $content=null);
33
34 public static function getClass()
35 {
36 return function_exists('get_called_class') ? get_called_class() : __CLASS__;
37 }
38
39 /**
40 * Instantiate class and get HTML for shortcode
41 *
42 * @param array $atts string
43 * @param string $content Optional
44 *
45 * @return string (see above)
46 */
47 public static function shortcode($atts, $content = null)
48 {
49 $class = self::getClass();
50 $instance = new $class($atts, $content);
51 return $instance->getHTML($atts, $content);
52 }
53
54 /**
55 * Create an LM variable for each shortcode class
56 * instance
57 */
58 protected function __construct()
59 {
60 $this->LM = Leaflet_Map::init();
61 }
62 }