*/ // Exit if accessed directly if (!defined('ABSPATH')) { exit; } /** * Leaflet_Map_Plugin_Option */ class Leaflet_Map_Plugin_Option { /** * Default Value * * @var varies $default */ public $default = ''; /** * Input type ex: ('text', 'select', 'checkbox') * * @var string $type */ public $type; /** * Optional used for select; maybe checkbox/radio * * @var array $options */ public $options = array(); /** * Optional used for label under input * * @var string $helptext */ public $helptext = ''; /** * Instantiate class * * @param array $details A list of options */ function __construct($details = array()) { if (!$details) { // just an empty db entry (for now) // nothing to store, nothing to render return; } $option_filter = array( 'display_name' => FILTER_SANITIZE_STRING, 'default' => null, 'type' => FILTER_SANITIZE_STRING, 'options' => array( 'filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FORCE_ARRAY ), 'helptext' => null ); // get matching keys only $details = array_intersect_key($details, $option_filter); // apply filter $details = filter_var_array($details, $option_filter); foreach ($details as $key => $value) { $this->$key = $value; } } /** * Renders a widget * * @param string $name widget name * @param varies $value widget value * * @return HTML */ function widget ($name, $value) { switch ($this->type) { case 'text': ?> />