Completed
Push — master ( a769f5...172323 )
by Justin
07:02
created

render_content()   B

Complexity

Conditions 5
Paths 9

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 5
eloc 11
c 2
b 0
f 0
nc 9
nop 0
dl 0
loc 20
rs 8.8571
1
<?php
2
3
if ( ! class_exists( 'WP_Customize_Control' ) ) {
4
    return;
5
}
6
7
/**
8
 * Custom control for Customizer.
9
 *
10
 * Allows us to have a width and a height input for thumbnail settings.
11
 *
12
 * @package WP eCommerce
13
 * @subpackage Customizer
14
 * @since 4.0
15
 */
16
17
/**
18
 * Thumbnail setting control for WxH settings in Customizer.
19
 *
20
 * @todo Move to its own file.
21
 * @since 4.0
22
 */
23
class WPSC_Customizer_Thumbnail_Control extends WP_Customize_Control {
24
25
    public $html = array();
26
    public $type = 'wpsc-thumbnail';
27
28
    public function build_field_html( $key, $setting, $label ) {
29
        $value = '';
30
31
        if ( isset( $this->settings[ $key ] ) ) {
32
            $value = $this->settings[ $key ]->value();
33
        }
34
35
        $this->html[] = '<div><label>' . $label . '<br /><input type="number" value="' . esc_attr( $value ) . '" ' . $this->get_link( $key ).' /></label>
36
        <p>' . $this->description . '</p></div>';
37
    }
38
39
	/**
40
	 * Op since we're using JS template.
41
	 *
42
	 * @since 4.3.0
43
	 * @access protected
44
	 */
45
	protected function render_content() {
46
        $keys = array_keys( get_object_vars( $this ) );
47
48
        foreach ( $keys as $key ) {
49
            if ( isset( $args[ $key ] ) ) {
50
                    $this->$key = $args[ $key ];
51
            }
52
        }
53
54
        $output =  '<label class="customize-control-title">' . esc_html( $this->label ) .'</label>';
0 ignored issues
show
introduced by
Expected 1 space after "="; 2 found
Loading history...
55
56
        echo $output;
57
58
        foreach( $this->settings as $key => $value ) {
59
            $label = absint( $key ) ? __( 'Height', 'wp-e-commerce' ) : __( 'Width', 'wp-e-commerce' );
60
            $this->build_field_html( $key, $value, $label );
61
        }
62
63
        echo implode( '', $this->html );
64
    }
65
66
}
67