forked from gambitph/Titan-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-option-radio.php
49 lines (40 loc) · 1.21 KB
/
class-option-radio.php
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
45
46
47
48
49
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class TitanFrameworkOptionRadio extends TitanFrameworkOption {
public $defaultSecondarySettings = array(
'options' => array(),
);
/*
* Display for options and meta
*/
public function display() {
$this->echoOptionHeader( true );
echo "<fieldset>";
foreach ( $this->settings['options'] as $value => $label ) {
printf('<label for="%s"><input id="%s" type="radio" name="%s" value="%s" %s/> %s</label><br>',
$this->getID() . $value,
$this->getID() . $value,
$this->getID(),
esc_attr( $value ),
checked( $this->getValue(), $value, false ),
$label
);
}
echo "</fieldset>";
$this->echoOptionFooter( 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(),
'choices' => $this->settings['options'],
'type' => 'radio',
'description' => $this->settings['desc'],
'priority' => $priority,
) ) );
}
}