| Total Complexity | 2 |
| Complexity/F | 2 |
| Lines of Code | 22 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | wp.customize.controlConstructor['kirki-date'] = wp.customize.kirkiDynamicControl.extend({ |
||
| 2 | |||
| 3 | initKirkiControl: function() { |
||
| 4 | |||
| 5 | var control = this; |
||
|
|
|||
| 6 | |||
| 7 | // Only add in WP 4.9+. |
||
| 8 | if ( _.isUndefined( wp.customize.DateTimeControl ) ) { |
||
| 9 | return; |
||
| 10 | } |
||
| 11 | |||
| 12 | // New method for the DateTime control. |
||
| 13 | wp.customize.control.add( new wp.customize.DateTimeControl( control.id, { |
||
| 14 | section: control.params.section, |
||
| 15 | priority: control.params.priority, |
||
| 16 | label: control.params.label, |
||
| 17 | description: control.params.description, |
||
| 18 | settings: { 'default': control.id }, |
||
| 19 | 'default': control.params['default'] |
||
| 20 | } ) ); |
||
| 21 | } |
||
| 22 | }); |
||
| 23 |
Since ECMAScript 6, you can create block-scoped vars or constants with the keywords
letorconst. These variables/constants are only valid in the code block where they have been declared.Consider the following two pieces of code:
and
The variable is not defined otuside of its block. This limits bleeding of variables into other contexts.
To know more about this ECMA6 feature, look at the MDN pages on let and const.