Passed
Pull Request — master (#258)
by
unknown
04:57
created

RangeControl::content_template()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 30
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 30
c 2
b 0
f 1
dl 0
loc 30
rs 9.44
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Flynt\Customizer;
4
5
class RangeControl extends \WP_Customize_Control
6
{
7
    public $type = 'flynt-range';
8
    public $unit = '';
9
10
    /**
11
     * Refresh the parameters passed to the JavaScript via JSON.
12
     */
13
    public function to_json() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
14
    {
15
        parent::to_json();
16
        $this->json['id'] = $this->id;
0 ignored issues
show
Deprecated Code introduced by
The property WP_Customize_Control::$json has been deprecated: It is better to just call the json() method ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

16
        /** @scrutinizer ignore-deprecated */ $this->json['id'] = $this->id;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
17
        $this->json['link'] = $this->get_link();
0 ignored issues
show
Deprecated Code introduced by
The property WP_Customize_Control::$json has been deprecated: It is better to just call the json() method ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

17
        /** @scrutinizer ignore-deprecated */ $this->json['link'] = $this->get_link();

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
18
        $this->json['value'] = $this->value();
0 ignored issues
show
Deprecated Code introduced by
The property WP_Customize_Control::$json has been deprecated: It is better to just call the json() method ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

18
        /** @scrutinizer ignore-deprecated */ $this->json['value'] = $this->value();

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
19
        $this->json['unit'] = $this->unit;
0 ignored issues
show
Deprecated Code introduced by
The property WP_Customize_Control::$json has been deprecated: It is better to just call the json() method ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

19
        /** @scrutinizer ignore-deprecated */ $this->json['unit'] = $this->unit;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
20
        $this->json['input_attrs'] = $this->input_attrs;
0 ignored issues
show
Deprecated Code introduced by
The property WP_Customize_Control::$json has been deprecated: It is better to just call the json() method ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

20
        /** @scrutinizer ignore-deprecated */ $this->json['input_attrs'] = $this->input_attrs;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
21
        $this->json['default'] = $this->default ?? $this->setting->default;
0 ignored issues
show
Bug Best Practice introduced by
The property default does not exist on Flynt\Customizer\RangeControl. Did you maybe forget to declare it?
Loading history...
Bug introduced by
The property default does not exist on string.
Loading history...
Deprecated Code introduced by
The property WP_Customize_Control::$json has been deprecated: It is better to just call the json() method ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

21
        /** @scrutinizer ignore-deprecated */ $this->json['default'] = $this->default ?? $this->setting->default;

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
22
    }
23
24
    /**
25
     * Don't render the control content from PHP, as it's rendered via JS on load.
26
     */
27
    public function render_content() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
28
    {
29
    }
30
31
    /**
32
     * Render a JS template for control display.
33
     */
34
    public function content_template() // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
35
    {
36
        ?>
37
        <# if ( data.label ) { #><label for="{{{ data.id }}}" class="customize-control-title">{{{ data.label }}} ({{{ data.unit }}})</label><# } #>
38
        <# if ( data.description ) { #><span class="description customize-control-description">{{{ data.description }}}</span><# } #>
39
40
        <div class="customize-control-notifications-container"></div>
41
42
        <div class="customize-control-content">
43
            <div class="flynt-range-field">
44
                <input
45
                    type="range"
46
                    data-change="number"
47
                    value="{{{ data.value }}}"
48
                    {{{ data.link }}}
49
                    <# _.each(_.extend({'class': 'flynt-range flynt-range-slider'}, data.input_attrs), function(value, key) { #>
50
                        {{{ key }}}="{{ value }}"
51
                    <# }); #>
52
                >
53
                <input
54
                    type="number"
55
                    data-change="slider"
56
                    value="{{{ data.value }}}"
57
                    id="{{{ data.id }}}"
58
                    {{{ data.link }}}
59
                    <# _.each(_.extend({'class': 'flynt-range flynt-range-number'}, data.input_attrs), function(value, key) { #>
60
                        {{{ key }}}="{{ value }}"
61
                    <# }); #>
62
                >
63
                <button type="button" class="flynt-range-reset button button-secondary" data-default="{{{ data.default }}}"><?php esc_html_e('Default', 'flynt'); ?></button>
64
            </div>
65
        </div>
66
67
        <?php
68
    }
69
}
70