| Conditions | 4 |
| Paths | 4 |
| Total Lines | 56 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 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 | public function enqueue() { |
||
| 94 | |||
| 95 | // Build the suffix for the script. |
||
| 96 | $suffix = ''; |
||
| 97 | $suffix .= ( ! defined( 'SCRIPT_DEBUG' ) || true !== SCRIPT_DEBUG ) ? '.min' : ''; |
||
| 98 | |||
| 99 | // The Kirki plugin URL. |
||
| 100 | $kirki_url = trailingslashit( Kirki::$url ); |
||
| 101 | |||
| 102 | // Enqueue ColorPicker. |
||
| 103 | wp_enqueue_script( 'wp-color-picker-alpha', trailingslashit( Kirki::$url ) . 'assets/vendor/wp-color-picker-alpha/wp-color-picker-alpha.js', array( 'wp-color-picker' ), KIRKI_VERSION, true ); |
||
| 104 | wp_enqueue_style( 'wp-color-picker' ); |
||
| 105 | |||
| 106 | // Enqueue selectWoo. |
||
| 107 | wp_enqueue_script( 'selectWoo', trailingslashit( Kirki::$url ) . 'assets/vendor/selectWoo/js/selectWoo.full.js', array( 'jquery' ), '1.0.1', true ); |
||
| 108 | wp_enqueue_style( 'selectWoo', trailingslashit( Kirki::$url ) . 'assets/vendor/selectWoo/css/selectWoo.css', array(), '1.0.1' ); |
||
| 109 | wp_enqueue_style( 'kirki-selectWoo', trailingslashit( Kirki::$url ) . 'assets/vendor/selectWoo/kirki.css', null ); |
||
| 110 | |||
| 111 | // Enqueue the script. |
||
| 112 | wp_enqueue_script( |
||
| 113 | 'kirki-script', |
||
| 114 | "{$kirki_url}controls/js/script{$suffix}.js", |
||
| 115 | array( |
||
| 116 | 'jquery', |
||
| 117 | 'customize-base', |
||
| 118 | 'wp-color-picker-alpha', |
||
| 119 | 'selectWoo', |
||
| 120 | 'jquery-ui-button', |
||
| 121 | 'jquery-ui-datepicker', |
||
| 122 | ), |
||
| 123 | KIRKI_VERSION |
||
| 124 | ); |
||
| 125 | |||
| 126 | wp_localize_script( |
||
| 127 | 'kirki-script', |
||
| 128 | 'kirkiL10n', |
||
| 129 | array( |
||
| 130 | 'isScriptDebug' => ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ), |
||
| 131 | 'noFileSelected' => esc_attr__( 'No File Selected', 'kirki' ), |
||
| 132 | 'remove' => esc_attr__( 'Remove', 'kirki' ), |
||
| 133 | 'default' => esc_attr__( 'Default', 'kirki' ), |
||
| 134 | 'selectFile' => esc_attr__( 'Select File', 'kirki' ), |
||
| 135 | 'standardFonts' => esc_attr__( 'Standard Fonts', 'kirki' ), |
||
| 136 | 'googleFonts' => esc_attr__( 'Google Fonts', 'kirki' ), |
||
| 137 | 'defaultCSSValues' => esc_attr__( 'CSS Defaults', 'kirki' ), |
||
| 138 | 'defaultBrowserFamily' => esc_attr__( 'Default Browser Font-Family', 'kirki' ), |
||
| 139 | ) |
||
| 140 | ); |
||
| 141 | |||
| 142 | $suffix = str_replace( '.min', '', $suffix ); |
||
| 143 | // Enqueue the style. |
||
| 144 | wp_enqueue_style( |
||
| 145 | 'kirki-styles', |
||
| 146 | "{$kirki_url}controls/css/styles{$suffix}.css", |
||
| 147 | array(), |
||
| 148 | KIRKI_VERSION |
||
| 149 | ); |
||
| 235 |