| Conditions | 33 |
| Paths | > 20000 |
| Total Lines | 409 |
| Code Lines | 334 |
| 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 |
||
| 40 | public function custom_css() { |
||
| 41 | |||
| 42 | $css = ''; |
||
| 43 | |||
| 44 | $config = apply_filters( 'kirki/config', array() ); |
||
| 45 | if ( ! isset( $config['color_accent'] ) && ! isset( $config['color_back'] ) ) { |
||
| 46 | return; |
||
| 47 | } |
||
| 48 | $back = isset( $config['color_back'] ) ? $config['color_back'] : false; |
||
| 49 | $back_obj = ( $back ) ? ariColor::newColor( $back ) : false; |
||
| 50 | if ( $back ) { |
||
| 51 | $text_on_back = ( 60 > $back_obj->lightness ) ? |
||
| 52 | $back_obj->getNew( 'lightness', $back_obj->lightness + 60 )->toCSS( $back_obj->mode ) : |
||
| 53 | $back_obj->getNew( 'lightness', $back_obj->lightness - 60 )->toCSS( $back_obj->mode ); |
||
| 54 | $border_on_back = ( 50 < $back_obj->lightness ) ? |
||
| 55 | $back_obj->getNew( 'lightness', $back_obj->lightness - 4 )->toCSS( $back_obj->mode ) : |
||
| 56 | $back_obj->getNew( 'lightness', $back_obj->lightness + 4 )->toCSS( $back_obj->mode ); |
||
| 57 | $back_on_back = ( 90 < $back_obj->lightness ) ? |
||
| 58 | $back_obj->getNew( 'lightness', $back_obj->lightness - 6 )->toCSS( $back_obj->mode ) : |
||
| 59 | $back_obj->getNew( 'lightness', $back_obj->lightness + 11 )->toCSS( $back_obj->mode ); |
||
| 60 | $hover_on_back = ( 90 < $back_obj->lightness ) ? |
||
| 61 | $back_obj->getNew( 'lightness', $back_obj->lightness - 3 )->toCSS( $back_obj->mode ) : |
||
| 62 | $back_obj->getNew( 'lightness', $back_obj->lightness + 3 )->toCSS( $back_obj->mode ); |
||
| 63 | $arrows_on_back = ( 50 > $back_obj->lightness ) ? |
||
| 64 | $back_obj->getNew( 'lightness', $back_obj->lightness + 30 )->toCSS( $back_obj->mode ) : |
||
| 65 | $back_obj->getNew( 'lightness', $back_obj->lightness - 30 )->toCSS( $back_obj->mode ); |
||
| 66 | $back_disabled_obj = ( 35 < $back_obj->lightness ) ? |
||
| 67 | $back_obj->getNew( 'lightness', $back_obj->lightness - 30 ) : |
||
| 68 | $back_obj->getNew( 'lightness', $back_obj->lightness + 30 ); |
||
| 69 | $back_disabled = $back_disabled_obj->toCSS( $back_disabled_obj->mode ); |
||
| 70 | $text_on_back_disabled = ( 60 > $back_disabled_obj->lightness ) ? |
||
| 71 | $back_disabled_obj->getNew( 'lightness', $back_disabled_obj->lightness + 60 )->toCSS( $back_disabled_obj->mode ) : |
||
| 72 | $back_disabled_obj->getNew( 'lightness', $back_disabled_obj->lightness - 60 )->toCSS( $back_disabled_obj->mode ); |
||
| 73 | $border_on_back_disabled = ( 50 < $back_disabled_obj->lightness ) ? |
||
| 74 | $back_disabled_obj->getNew( 'lightness', $back_disabled_obj->lightness - 4 )->toCSS( $back_disabled_obj->mode ) : |
||
| 75 | $back_disabled_obj->getNew( 'lightness', $back_disabled_obj->lightness + 4 )->toCSS( $back_disabled_obj->mode ); |
||
| 76 | } |
||
| 77 | $accent = ( isset( $config['color_accent'] ) ) ? $config['color_accent'] : false; |
||
| 78 | $accent_obj = ( $accent ) ? ariColor::newColor( $accent ) : false; |
||
| 79 | if ( $accent ) { |
||
| 80 | $text_on_accent = ( 60 > $accent_obj->lightness ) ? |
||
| 81 | $accent_obj->getNew( 'lightness', $accent_obj->lightness + 60 )->toCSS( $accent_obj->mode ) : |
||
| 82 | $accent_obj->getNew( 'lightness', $accent_obj->lightness - 60 )->toCSS( $accent_obj->mode ); |
||
| 83 | $border_on_accent = ( 50 < $accent_obj->lightness ) ? |
||
| 84 | $accent_obj->getNew( 'lightness', $accent_obj->lightness - 4 )->toCSS( $accent_obj->mode ) : |
||
| 85 | $accent_obj->getNew( 'lightness', $accent_obj->lightness + 4 )->toCSS( $accent_obj->mode ); |
||
| 86 | $accent_disabled_obj = ( 35 < $accent_obj->lightness ) ? |
||
| 87 | $accent_obj->getNew( 'lightness', $accent_obj->lightness - 30 ) : |
||
| 88 | $accent_obj->getNew( 'lightness', $accent_obj->lightness + 30 ); |
||
| 89 | $accent_disabled = $accent_disabled_obj->toCSS( $accent_disabled_obj->mode ); |
||
| 90 | $text_on_accent_disabled = ( 60 > $accent_disabled_obj->lightness ) ? |
||
| 91 | $accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness + 60 )->toCSS( $accent_disabled_obj->mode ) : |
||
| 92 | $accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness - 60 )->toCSS( $accent_disabled_obj->mode ); |
||
| 93 | $border_on_accent_disabled = ( 50 < $accent_disabled_obj->lightness ) ? |
||
| 94 | $accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness - 4 )->toCSS( $accent_disabled_obj->mode ) : |
||
| 95 | $accent_disabled_obj->getNew( 'lightness', $accent_disabled_obj->lightness + 4 )->toCSS( $accent_disabled_obj->mode ); |
||
| 96 | } |
||
| 97 | |||
| 98 | if ( $back ) { |
||
| 99 | $elements = array( |
||
| 100 | '.wp-full-overlay-sidebar', |
||
| 101 | '#customize-controls .customize-info .accordion-section-title', |
||
| 102 | '#customize-controls .panel-meta.customize-info .accordion-section-title:hover', |
||
| 103 | '#customize-theme-controls .accordion-section-title', |
||
| 104 | '.customize-section-title', |
||
| 105 | '#customize-theme-controls .control-section-themes .accordion-section-title', |
||
| 106 | '#customize-theme-controls .control-section-themes .accordion-section-title', |
||
| 107 | '#customize-theme-controls .control-section-themes .accordion-section-title:hover', |
||
| 108 | ); |
||
| 109 | |||
| 110 | $css .= implode( ',', $elements ) . '{'; |
||
| 111 | $css .= 'background:' . $back . ';'; |
||
| 112 | $css .= 'color:' . $text_on_back . ';'; |
||
|
|
|||
| 113 | $css .= '}'; |
||
| 114 | |||
| 115 | $elements = array( |
||
| 116 | '#customize-controls .customize-info .panel-title', |
||
| 117 | '#customize-controls .customize-pane-child .customize-section-title h3', |
||
| 118 | '#customize-controls .customize-pane-child h3.customize-section-title', |
||
| 119 | '.customize-control', |
||
| 120 | '#customize-controls .description', |
||
| 121 | ); |
||
| 122 | $css .= implode( ',', $elements ) . '{'; |
||
| 123 | $css .= 'color:' . $text_on_back . ';'; |
||
| 124 | $css .= '}'; |
||
| 125 | |||
| 126 | $elements = array( |
||
| 127 | '#customize-controls .customize-info', |
||
| 128 | '#customize-header-actions', |
||
| 129 | '.customize-section-title', |
||
| 130 | ); |
||
| 131 | $css .= implode( ',', $elements ) . '{'; |
||
| 132 | $css .= 'border-bottom-color: ' . $border_on_back . ';'; |
||
| 133 | $css .= '}'; |
||
| 134 | |||
| 135 | $elements = array( |
||
| 136 | '.wp-full-overlay-sidebar .wp-full-overlay-header', |
||
| 137 | '.customize-controls-close', |
||
| 138 | '.expanded .wp-full-overlay-footer', |
||
| 139 | ); |
||
| 140 | $css .= implode( ',', $elements ) . '{'; |
||
| 141 | $css .= 'color:' . $text_on_back . ';'; |
||
| 142 | $css .= 'background-color:' . $back_on_back . ';'; |
||
| 143 | $css .= 'border-color:' . $border_on_back . ';'; |
||
| 144 | $css .= '}'; |
||
| 145 | |||
| 146 | $elements = array( |
||
| 147 | '.accordion-section', |
||
| 148 | '#customize-theme-controls .customize-pane-child.accordion-section-content', |
||
| 149 | ); |
||
| 150 | $css .= implode( ',', $elements ) . '{'; |
||
| 151 | $css .= 'background:' . $back_on_back . ';'; |
||
| 152 | $css .= '}'; |
||
| 153 | |||
| 154 | $elements = array( |
||
| 155 | '#accordion-section-themes+.control-section', |
||
| 156 | '#customize-theme-controls .control-section:last-of-type.open', |
||
| 157 | '#customize-theme-controls .control-section:last-of-type > .accordion-section-title', |
||
| 158 | '#customize-theme-controls .control-section.open', |
||
| 159 | ); |
||
| 160 | $css .= implode( ',', $elements ) . '{'; |
||
| 161 | $css .= 'border-bottom-color:' . $border_on_back . ';'; |
||
| 162 | $css .= 'border-top-color:' . $border_on_back . ';'; |
||
| 163 | $css .= '}'; |
||
| 164 | |||
| 165 | $elements = array( |
||
| 166 | '#customize-theme-controls .accordion-section-title', |
||
| 167 | ); |
||
| 168 | $css .= implode( ',', $elements ) . '{'; |
||
| 169 | $css .= 'border-bottom-color:' . $border_on_back . ';'; |
||
| 170 | $css .= 'border-left-color:' . $border_on_back . ';'; |
||
| 171 | $css .= '}'; |
||
| 172 | |||
| 173 | $elements = array( |
||
| 174 | '#customize-theme-controls .control-section-themes .accordion-section-title', |
||
| 175 | '#customize-theme-controls .control-section-themes .accordion-section-title:hover', |
||
| 176 | ); |
||
| 177 | $css .= implode( ',', $elements ) . '{'; |
||
| 178 | $css .= 'border-bottom-color:' . $border_on_back . ';'; |
||
| 179 | $css .= 'border-top-color:' . $border_on_back . ';'; |
||
| 180 | $css .= 'border-bottom-color:' . $border_on_back . ';'; |
||
| 181 | $css .= '}'; |
||
| 182 | |||
| 183 | $elements = array( |
||
| 184 | '#customize-theme-controls .accordion-section-title:after', |
||
| 185 | ); |
||
| 186 | $css .= implode( ',', $elements ) . '{'; |
||
| 187 | $css .= 'color:' . $arrows_on_back . ';'; |
||
| 188 | $css .= '}'; |
||
| 189 | |||
| 190 | $elements = array( |
||
| 191 | '.wp-core-ui .button', |
||
| 192 | '.wp-core-ui .button-secondary', |
||
| 193 | ); |
||
| 194 | $css .= implode( ',', $elements ) . '{'; |
||
| 195 | $css .= 'background-color:' . $back . ';'; |
||
| 196 | $css .= 'border-color:' . $border_on_back . ';'; |
||
| 197 | $css .= 'box-shadow:0 1px 0 ' . $border_on_back . ';'; |
||
| 198 | $css .= '-webkit-box-shadow:0 1px 0 ' . $border_on_back . ';'; |
||
| 199 | $css .= 'text-shadow:0 -1px 1px ' . $border_on_back . ', 1px 0 1px ' . $border_on_back . ', 0 1px 1px ' . $border_on_back . ', -1px 0 1px ' . $border_on_back . ';'; |
||
| 200 | $css .= 'color:' . $text_on_back . ';'; |
||
| 201 | $css .= '}'; |
||
| 202 | |||
| 203 | $css .= '@media screen and (max-width: 640px) {.customize-controls-preview-toggle{'; |
||
| 204 | $css .= 'background-color:' . $back . ';'; |
||
| 205 | $css .= 'border-color:' . $border_on_back . ';'; |
||
| 206 | $css .= 'box-shadow:0 1px 0 ' . $border_on_back . ';'; |
||
| 207 | $css .= '-webkit-box-shadow:0 1px 0 ' . $border_on_back . ';'; |
||
| 208 | $css .= 'text-shadow:0 -1px 1px ' . $border_on_back . ', 1px 0 1px ' . $border_on_back . ', 0 1px 1px ' . $border_on_back . ', -1px 0 1px ' . $border_on_back . ';'; |
||
| 209 | $css .= 'color:' . $text_on_back . ';'; |
||
| 210 | $css .= '}}'; |
||
| 211 | |||
| 212 | $elements = array( |
||
| 213 | '.wp-core-ui .button.focus', |
||
| 214 | '.wp-core-ui .button.hover', |
||
| 215 | '.wp-core-ui .button:focus', |
||
| 216 | '.wp-core-ui .button:hover', |
||
| 217 | '.wp-core-ui .button-secondary.focus', |
||
| 218 | '.wp-core-ui .button-secondary.hover', |
||
| 219 | '.wp-core-ui .button-secondary:focus', |
||
| 220 | '.wp-core-ui .button-secondary:hover', |
||
| 221 | '.customize-panel-back', |
||
| 222 | '.customize-section-back', |
||
| 223 | ); |
||
| 224 | $css .= implode( ',', $elements ) . '{'; |
||
| 225 | $css .= 'background-color:' . $back_on_back . ';'; |
||
| 226 | $css .= 'border-color:' . $border_on_back . ';'; |
||
| 227 | $css .= 'box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
||
| 228 | $css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
||
| 229 | $css .= 'text-shadow: 0 -1px 1px ' . $border_on_back . ', 1px 0 1px ' . $border_on_back . ', 0 1px 1px ' . $border_on_back . ', -1px 0 1px ' . $border_on_back . ';'; |
||
| 230 | $css .= 'color:' . $text_on_back . ';'; |
||
| 231 | $css .= '}'; |
||
| 232 | |||
| 233 | $css .= '@media screen and (max-width: 640px) {.customize-controls-preview-toggle.focus,.customize-controls-preview-toggle.hover,.customize-controls-preview-toggle:focus,.customize-controls-preview-toggle:hover{'; |
||
| 234 | $css .= 'background-color:' . $back_on_back . ';'; |
||
| 235 | $css .= 'border-color:' . $border_on_back . ';'; |
||
| 236 | $css .= 'box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
||
| 237 | $css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
||
| 238 | $css .= 'text-shadow: 0 -1px 1px ' . $border_on_back . ', 1px 0 1px ' . $border_on_back . ', 0 1px 1px ' . $border_on_back . ', -1px 0 1px ' . $border_on_back . ';'; |
||
| 239 | $css .= 'color:' . $text_on_back . ';'; |
||
| 240 | $css .= '}}'; |
||
| 241 | $elements = array( |
||
| 242 | '.customize-control-kirki-background .background-attachment .buttonset .switch-label', |
||
| 243 | '.customize-control-kirki-background .background-size .buttonset .switch-label', |
||
| 244 | '.customize-control-kirki-radio-buttonset .buttonset .switch-label', |
||
| 245 | ); |
||
| 246 | $css .= implode( ',', $elements ) . '{'; |
||
| 247 | $css .= 'color:' . $text_on_back . ';'; |
||
| 248 | $css .= '}'; |
||
| 249 | |||
| 250 | $elements = array( |
||
| 251 | '.wp-color-result', |
||
| 252 | ); |
||
| 253 | $css .= implode( ',', $elements ) . '{'; |
||
| 254 | $css .= 'border-color:' . $border_on_back . ';'; |
||
| 255 | $css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
||
| 256 | $css .= 'box-shadow: 0 1px 0 ' . $border_on_back . ';'; |
||
| 257 | $css .= '}'; |
||
| 258 | |||
| 259 | $elements = array( |
||
| 260 | '.wp-color-result:focus', |
||
| 261 | '.wp-color-result:hover', |
||
| 262 | ); |
||
| 263 | $css .= implode( ',', $elements ) . '{'; |
||
| 264 | $css .= 'border-color:' . $border_on_back . ';'; |
||
| 265 | $css .= 'background:' . $back_on_back . ';'; |
||
| 266 | $css .= '}'; |
||
| 267 | |||
| 268 | $elements = array( |
||
| 269 | '.wp-color-result:after', |
||
| 270 | ); |
||
| 271 | $css .= implode( ',', $elements ) . '{'; |
||
| 272 | $css .= 'border-color:' . $border_on_back . ';'; |
||
| 273 | $css .= 'background:' . $back . ';'; |
||
| 274 | $css .= 'color:' . $text_on_back . ';'; |
||
| 275 | $css .= '}'; |
||
| 276 | |||
| 277 | $elements = array( |
||
| 278 | '.wp-color-result:focus:after', |
||
| 279 | '.wp-color-result:hover:after', |
||
| 280 | ); |
||
| 281 | $css .= implode( ',', $elements ) . '{'; |
||
| 282 | $css .= 'color:' . $text_on_back . ';'; |
||
| 283 | $css .= '}'; |
||
| 284 | |||
| 285 | $elements = array( |
||
| 286 | '.customize-control input[type=tel]', |
||
| 287 | '.customize-control input[type=url]', |
||
| 288 | '.customize-control input[type=text]', |
||
| 289 | '.customize-control input[type=password]', |
||
| 290 | '.customize-control input[type=email]', |
||
| 291 | '.customize-control input[type=number]', |
||
| 292 | '.customize-control input[type=search]', |
||
| 293 | '.customize-control input[type=radio]', |
||
| 294 | '.customize-control input[type=checkbox]', |
||
| 295 | '.customize-control select', |
||
| 296 | '.select2-container--default .select2-selection--single', |
||
| 297 | '.select2-container--default .select2-selection--multiple', |
||
| 298 | ); |
||
| 299 | $css .= implode( ',', $elements ) . '{'; |
||
| 300 | $css .= 'background:' . $back . ';'; |
||
| 301 | $css .= 'border-color:' . $border_on_back . ';'; |
||
| 302 | $css .= 'color:' . $text_on_back . ';'; |
||
| 303 | $css .= '}'; |
||
| 304 | |||
| 305 | $css .= '.customize-control-kirki-slider input[type=range]::-webkit-slider-thumb{background-color:' . $accent . ';}'; |
||
| 306 | $css .= '.customize-control-kirki-slider input[type=range]::-moz-range-thumb{background-color:' . $accent . ';}'; |
||
| 307 | $css .= '.customize-control-kirki-slider input[type=range]::-ms-thumb{background-color:' . $accent . ';}'; |
||
| 308 | |||
| 309 | $css .= '.customize-control-kirki-slider input[type=range]{background:' . $back . ';}'; |
||
| 310 | |||
| 311 | $elements = array( |
||
| 312 | '.select2-container--default .select2-selection--single .select2-selection__rendered', |
||
| 313 | ); |
||
| 314 | $css .= implode( ',', $elements ) . '{'; |
||
| 315 | $css .= 'color:' . $text_on_back . ';'; |
||
| 316 | $css .= '}'; |
||
| 317 | |||
| 318 | $elements = array( |
||
| 319 | '.wp-full-overlay-footer .devices', |
||
| 320 | ); |
||
| 321 | $css .= implode( ',', $elements ) . '{'; |
||
| 322 | $css .= 'background: none;'; |
||
| 323 | $css .= 'background: transparent;'; |
||
| 324 | $css .= 'box-shadow: none;'; |
||
| 325 | $css .= '-webkit-box-shadow: none;'; |
||
| 326 | $css .= '}'; |
||
| 327 | |||
| 328 | $css .= '.kirki-reset-section .dashicons{color:' . $back_on_back . ';}'; |
||
| 329 | |||
| 330 | } |
||
| 331 | |||
| 332 | if ( $back || $accent ) { |
||
| 333 | $elements = array( |
||
| 334 | '#customize-controls .control-section .accordion-section-title:focus', |
||
| 335 | '#customize-controls .control-section .accordion-section-title:hover', |
||
| 336 | '#customize-controls .control-section.open .accordion-section-title', |
||
| 337 | '#customize-controls .control-section:hover > .accordion-section-title', |
||
| 338 | '.customize-panel-back:focus', |
||
| 339 | '.customize-panel-back:hover', |
||
| 340 | '.customize-section-back:focus', |
||
| 341 | '.customize-section-back:hover', |
||
| 342 | ); |
||
| 343 | $css .= implode( ',', $elements ) . '{'; |
||
| 344 | $css .= ( $back ) ? 'background:' . $hover_on_back . ';' : ''; |
||
| 345 | $css .= ( $accent ) ? 'color:' . $accent . ';border-left-color:' . $accent . ';' : ''; |
||
| 346 | $css .= '}'; |
||
| 347 | |||
| 348 | $css .= '.customize-controls-close:hover{'; |
||
| 349 | $css .= ( $back ) ? 'background-color:' . $back . ';' : ''; |
||
| 350 | $css .= ( $accent ) ? 'color:' . $accent . ';border-color:' . $accent . ';' : ''; |
||
| 351 | $css .= '}'; |
||
| 352 | |||
| 353 | } |
||
| 354 | |||
| 355 | if ( $accent ) { |
||
| 356 | $elements = array( |
||
| 357 | '#customize-theme-controls .control-section .accordion-section-title:focus:after', |
||
| 358 | '#customize-theme-controls .control-section .accordion-section-title:hover:after', |
||
| 359 | '#customize-theme-controls .control-section.open .accordion-section-title:after', |
||
| 360 | '#customize-theme-controls .control-section:hover>.accordion-section-title:after', |
||
| 361 | ); |
||
| 362 | $css .= implode( ',', $elements ) . '{'; |
||
| 363 | $css .= 'color:' . $accent . ';'; |
||
| 364 | $css .= '}'; |
||
| 365 | |||
| 366 | $elements = array( |
||
| 367 | '.wp-core-ui .button.button-primary', |
||
| 368 | ); |
||
| 369 | $css .= implode( ',', $elements ) . '{'; |
||
| 370 | $css .= 'background-color:' . $accent . ';'; |
||
| 371 | $css .= 'border-color:' . $border_on_accent . ';'; |
||
| 372 | $css .= 'box-shadow:0 1px 0 ' . $border_on_accent . ';'; |
||
| 373 | $css .= '-webkit-box-shadow:0 1px 0 ' . $border_on_accent . ';'; |
||
| 374 | $css .= 'text-shadow:0 -1px 1px ' . $border_on_accent . ', 1px 0 1px ' . $border_on_accent . ', 0 1px 1px ' . $border_on_accent . ', -1px 0 1px ' . $border_on_accent . ';'; |
||
| 375 | $css .= 'color:' . $text_on_accent . ';'; |
||
| 376 | $css .= '}'; |
||
| 377 | |||
| 378 | $elements = array( |
||
| 379 | '.wp-core-ui .button.button-primary.focus', |
||
| 380 | '.wp-core-ui .button.button-primary.hover', |
||
| 381 | '.wp-core-ui .button.button-primary:focus', |
||
| 382 | '.wp-core-ui .button.button-primary:hover', |
||
| 383 | ); |
||
| 384 | $css .= implode( ',', $elements ) . '{'; |
||
| 385 | $css .= 'background-color:' . $accent . ';'; |
||
| 386 | $css .= 'border-color:' . $border_on_accent . ';'; |
||
| 387 | $css .= 'box-shadow: 0 1px 0 ' . $border_on_accent . ';'; |
||
| 388 | $css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_accent . ';'; |
||
| 389 | $css .= 'text-shadow: 0 -1px 1px ' . $border_on_accent . ', 1px 0 1px ' . $border_on_accent . ', 0 1px 1px ' . $border_on_accent . ', -1px 0 1px ' . $border_on_accent . ';'; |
||
| 390 | $css .= 'color:' . $text_on_accent . ';'; |
||
| 391 | $css .= '}'; |
||
| 392 | |||
| 393 | $elements = array( |
||
| 394 | '.wp-core-ui .button.button-primary-disabled', |
||
| 395 | '.wp-core-ui .button.button-primary.disabled', |
||
| 396 | '.wp-core-ui .button.button-primary:disabled', |
||
| 397 | '.wp-core-ui .button.button-primary[disabled]', |
||
| 398 | ); |
||
| 399 | $css .= implode( ',', $elements ) . '{'; |
||
| 400 | $css .= 'background-color:' . $accent_disabled . ' !important;'; |
||
| 401 | $css .= 'border-color: ' . $border_on_accent_disabled . ' !important;'; |
||
| 402 | $css .= 'box-shadow: 0 1px 0 ' . $border_on_accent_disabled . ' !important;'; |
||
| 403 | $css .= '-webkit-box-shadow: 0 1px 0 ' . $border_on_accent_disabled . ' !important;'; |
||
| 404 | $css .= 'text-shadow: 0 -1px 1px ' . $border_on_accent_disabled . ', 1px 0 1px ' . $border_on_accent_disabled . ', 0 1px 1px ' . $border_on_accent_disabled . ', -1px 0 1px ' . $border_on_accent_disabled . ' !important;'; |
||
| 405 | $css .= 'color:' . $text_on_accent_disabled . ' !important;'; |
||
| 406 | $css .= '}'; |
||
| 407 | |||
| 408 | $elements = array( |
||
| 409 | 'input[type=checkbox]:checked:before', |
||
| 410 | ); |
||
| 411 | if ( $accent ) { |
||
| 412 | $css .= implode( ',', $elements ) . '{'; |
||
| 413 | $css .= 'color:' . $accent . ';'; |
||
| 414 | $css .= '}'; |
||
| 415 | } |
||
| 416 | |||
| 417 | $elements = array( |
||
| 418 | '.select2-container--default .select2-results__option--highlighted[aria-selected]', |
||
| 419 | ); |
||
| 420 | $css .= implode( ',', $elements ) . '{'; |
||
| 421 | $css .= 'background-color:' . $accent . ';'; |
||
| 422 | $css .= 'color:' . $text_on_accent . ';'; |
||
| 423 | $css .= '}'; |
||
| 424 | |||
| 425 | $elements = array( |
||
| 426 | '.customize-control-kirki-radio-buttonset .buttonset .switch-input:checked + .switch-label', |
||
| 427 | '.customize-control-kirki-background .background-attachment .buttonset .switch-input:checked + .switch-label', |
||
| 428 | '.customize-control-kirki-background .background-size .buttonset .switch-input:checked + .switch-label', |
||
| 429 | ); |
||
| 430 | $css .= implode( ',', $elements ) . '{'; |
||
| 431 | $css .= 'background-color:' . $accent . ';'; |
||
| 432 | $css .= 'border-color:' . $border_on_accent . ';'; |
||
| 433 | $css .= 'color:' . $text_on_accent . ';'; |
||
| 434 | $css .= '}'; |
||
| 435 | } |
||
| 436 | |||
| 437 | if ( isset( $config['width'] ) ) { |
||
| 438 | $width = esc_attr( $config['width'] ); |
||
| 439 | $css .= '.wp-full-overlay-sidebar{width:' . $width . ';}'; |
||
| 440 | $css .= '.expanded .wp-full-overlay-footer{'; |
||
| 441 | $css .= ( false === strpos( $config['width'], 'calc' ) ) ? 'width:calc(' . $width . ' - 1px);' : 'width:' . $width; |
||
| 442 | $css .= '}'; |
||
| 443 | $css .= '.wp-full-overlay.expanded{margin-left:' . $width . ';}'; |
||
| 444 | $css .= '.wp-full-overlay.collapsed .wp-full-overlay-sidebar{margin-left: -' . $Width . ';}'; |
||
| 445 | } |
||
| 446 | |||
| 447 | echo '<style>' . $css . '</style>'; // WPCS: XSS ok. |
||
| 448 | } |
||
| 449 | } |
||
| 450 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: