Total Complexity | 4 |
Complexity/F | 1.33 |
Lines of Code | 18 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | /* global wp, _customizePostPreviewedQueriedObject */ |
||
2 | jQuery( document ).ready( function() { |
||
3 | |||
4 | var self; |
||
|
|||
5 | |||
6 | self = { |
||
7 | queriedPost: null |
||
8 | }; |
||
9 | if ( ! _.isUndefined( _customizePostPreviewedQueriedObject ) ) { |
||
10 | self.queriedPost = _customizePostPreviewedQueriedObject; |
||
11 | } |
||
12 | |||
13 | // Send the queried post object to the Customizer pane when ready. |
||
14 | wp.customize.bind( 'preview-ready', function() { |
||
15 | wp.customize.preview.bind( 'active', function() { |
||
16 | wp.customize.preview.send( 'queried-post', self.queriedPost ); |
||
17 | } ); |
||
18 | } ); |
||
19 | } ); |
||
20 |
Since ECMAScript 6, you can create block-scoped vars or constants with the keywords
let
orconst
. 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.