| 1 |
<?php |
| 2 |
// Not allowed by directly accessing. |
| 3 |
if(!defined('ABSPATH')){ |
| 4 |
die('Access not allowed!'); |
| 5 |
} |
| 6 |
/** |
| 7 |
* Plugin option form element class |
| 8 |
* Type Checkbox |
| 9 |
* |
| 10 |
* @package LoftLoader |
| 11 |
* @version 1.0 |
| 12 |
* @link http://www.loftocean.com/ |
| 13 |
* @author Suihai Huang from Loft Ocean Team |
| 14 |
|
| 15 |
* @since version 1.0 |
| 16 |
*/ |
| 17 |
|
| 18 |
if(!class_exists('LoftLoader_Checkbox')){ |
| 19 |
class LoftLoader_Checkbox extends LoftLoader_Form_Base{ |
| 20 |
/** |
| 21 |
* @description rewrite the content function |
| 22 |
*/ |
| 23 |
protected function content(){ |
| 24 |
$html = ''; |
| 25 |
if($this->options){ |
| 26 |
$value = $this->values; |
| 27 |
$class = ''; |
| 28 |
$id = ''; |
| 29 |
if(count($this->options) == 1){ |
| 30 |
$class = (isset($this->extra['class']) && $this->extra['class'])? ' class="' . $this->extra['class'] . '"' : ''; |
| 31 |
$id = (isset($this->extra['id']) && $this->extra['id']) ? ' id="'. $this->extra['id'] . '"' : ''; |
| 32 |
} |
| 33 |
foreach($this->options as $val=>$attr){ |
| 34 |
$checked = checked($value, $val, false); |
| 35 |
$disabled = (isset($attr['disabled']) && $attr['disabled']) ? ' disabled' : ''; |
| 36 |
$html .= '<label><input' . $id . $class . ' type="checkbox" name="' . $this->name . '" value="' . $val . '"' . $checked . $disabled . '>' . $attr['label'] . '<div class="on-off"><span></span></div></label>'; |
| 37 |
} |
| 38 |
} |
| 39 |
return $html; |
| 40 |
} |
| 41 |
} |
| 42 |
} |