forked from gambitph/Titan-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass-option-checkbox.php
More file actions
44 lines (36 loc) · 1.15 KB
/
class-option-checkbox.php
File metadata and controls
44 lines (36 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class TitanFrameworkOptionCheckbox extends TitanFrameworkOption {
/*
* Display for options and meta
*/
public function display() {
$this->echoOptionHeader();
?>
<label for="<?php echo $this->getID() ?>">
<input name="<?php echo $this->getID() ?>" type="checkbox" id="<?php echo $this->getID() ?>" value="1" <?php checked( $this->getValue(), 1 ) ?>>
<?php echo $this->getDesc( true ) ?>
</label>
<?php
$this->echoOptionFooter( false );
}
public function cleanValueForSaving( $value ) {
return $value != '1' ? '0' : '1';
}
public function cleanValueForGetting( $value ) {
return $value == '1' ? true : false;
}
/*
* Display for theme customizer
*/
public function registerCustomizerControl( $wp_customize, $section, $priority = 1 ) {
$wp_customize->add_control( new TitanFrameworkCustomizeControl( $wp_customize, $this->getID(), array(
'label' => $this->settings['name'],
'section' => $section->settings['id'],
'settings' => $this->getID(),
'type' => 'checkbox',
'description' => $this->settings['desc'],
'priority' => $priority,
) ) );
}
}