Conditions | 2 |
Paths | 1 |
Total Lines | 55 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
93 | protected function content_template() { |
||
94 | ?> |
||
95 | <# |
||
96 | var saveAs = 'url', |
||
97 | url = ''; |
||
98 | |||
99 | if ( ! _.isUndefined( data.choices ) && ! _.isUndefined( data.choices.save_as ) ) { |
||
100 | saveAs = data.choices.save_as; |
||
101 | } |
||
102 | if ( 'url' === saveAs ) { |
||
103 | url = data.value; |
||
104 | } |
||
105 | if ( 'array' === saveAs && data.value['url'] ) { |
||
106 | url = data.value['url']; |
||
107 | } |
||
108 | if ( 'id' === saveAs ) { |
||
109 | url = <?php echo ( is_int( $this->value() ) ) ? wp_get_attachment_url( $this->value() ) : "''"; ?> |
||
|
|||
110 | } |
||
111 | #> |
||
112 | <label> |
||
113 | <span class="customize-control-title"> |
||
114 | {{{ data.label }}} |
||
115 | </span> |
||
116 | <# if ( data.description ) { #> |
||
117 | <span class="description customize-control-description">{{{ data.description }}}</span> |
||
118 | <# } #> |
||
119 | </label> |
||
120 | <div class="image-wrapper attachment-media-view image-upload"> |
||
121 | <# if ( data.value['url'] || '' !== url ) { #> |
||
122 | <div class="thumbnail thumbnail-image"> |
||
123 | <img src="{{ url }}" alt="" /> |
||
124 | </div> |
||
125 | <# } else { #> |
||
126 | <div class="placeholder"> |
||
127 | <?php esc_attr_e( 'No File Selected', 'kirki' ); ?> |
||
128 | </div> |
||
129 | <# } #> |
||
130 | <div class="actions"> |
||
131 | <button class="button image-upload-remove-button<# if ( '' === url ) { #> hidden <# } #>"> |
||
132 | <?php esc_attr_e( 'Remove', 'kirki' ); ?> |
||
133 | </button> |
||
134 | <# if ( data.default && '' !== data.default ) { #> |
||
135 | <button type="button" class="button image-default-button"<# if ( data.default === data.value || ( ! _.isUndefined( data.value.url ) && data.default === data.value.url ) ) { #> style="display:none;"<# } #>> |
||
136 | <?php esc_attr_e( 'Default', 'kirki' ); ?> |
||
137 | </button> |
||
138 | <# } #> |
||
139 | <button type="button" class="button image-upload-button"> |
||
140 | <?php esc_attr_e( 'Select File', 'kirki' ); ?> |
||
141 | </button> |
||
142 | </div> |
||
143 | </div> |
||
144 | <# value = ( 'array' === saveAs ) ? JSON.stringify( data.value ) : data.value; #> |
||
145 | <input class="image-hidden-value" type="hidden" value='{{{ value }}}' {{{ data.link }}}> |
||
146 | <?php |
||
147 | } |
||
148 | } |
||
149 |