| Conditions | 13 |
| Paths | 16 |
| Total Lines | 53 |
| Code Lines | 27 |
| 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 |
||
| 114 | public function init() { |
||
| 115 | |||
| 116 | Kirki_Modules_Webfonts::get_instance(); |
||
| 117 | |||
| 118 | global $wp_customize; |
||
| 119 | |||
| 120 | $config = apply_filters( 'kirki_config', array() ); |
||
|
1 ignored issue
–
show
|
|||
| 121 | $priority = 999; |
||
| 122 | if ( isset( $config['styles_priority'] ) ) { |
||
| 123 | $priority = absint( $config['styles_priority'] ); |
||
|
1 ignored issue
–
show
|
|||
| 124 | } |
||
| 125 | |||
| 126 | // Allow completely disabling Kirki CSS output. |
||
| 127 | if ( ( defined( 'KIRKI_NO_OUTPUT' ) && true === KIRKI_NO_OUTPUT ) || ( isset( $config['disable_output'] ) && true === $config['disable_output'] ) ) { |
||
|
1 ignored issue
–
show
|
|||
| 128 | return; |
||
| 129 | } |
||
| 130 | |||
| 131 | $method = apply_filters( 'kirki_dynamic_css_method', 'inline' ); |
||
| 132 | if ( $wp_customize ) { |
||
| 133 | // If we're in the customizer, load inline no matter what. |
||
| 134 | add_action( 'wp_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority ); |
||
|
1 ignored issue
–
show
|
|||
| 135 | |||
| 136 | // If we're using file method, on save write the new styles. |
||
| 137 | if ( 'file' === $method ) { |
||
| 138 | $this->css_to_file = new Kirki_CSS_To_File(); |
||
| 139 | add_action( 'customize_save_after', array( $this->css_to_file, 'write_file' ) ); |
||
| 140 | } |
||
| 141 | return; |
||
| 142 | } |
||
| 143 | |||
| 144 | if ( 'file' === $method ) { |
||
| 145 | // Attempt to write the CSS to file. |
||
| 146 | $this->css_to_file = new Kirki_CSS_To_File(); |
||
| 147 | // If we succesd, load this file. |
||
| 148 | $failed = get_transient( 'kirki_css_write_to_file_failed' ); |
||
|
1 ignored issue
–
show
|
|||
| 149 | // If writing CSS to file hasn't failed, just enqueue this file. |
||
| 150 | if ( ! $failed ) { |
||
| 151 | add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_compiled_file' ), $priority ); |
||
| 152 | return; |
||
| 153 | } |
||
| 154 | } |
||
| 155 | |||
| 156 | // If we are in the customizer, load CSS using inline-styles. |
||
| 157 | // If we are in the frontend AND self::$ajax is true, then load dynamic CSS using AJAX. |
||
| 158 | if ( ( true === self::$ajax ) || ( isset( $config['inline_css'] ) && false === $config['inline_css'] ) ) { |
||
| 159 | add_action( 'wp_enqueue_scripts', array( $this, 'frontend_styles' ), $priority ); |
||
| 160 | add_action( 'wp_ajax_kirki_dynamic_css', array( $this, 'ajax_dynamic_css' ) ); |
||
| 161 | add_action( 'wp_ajax_nopriv_kirki_dynamic_css', array( $this, 'ajax_dynamic_css' ) ); |
||
| 162 | return; |
||
| 163 | } |
||
| 164 | |||
| 165 | // If we got this far then add styles inline. |
||
| 166 | add_action( 'wp_enqueue_scripts', array( $this, 'inline_dynamic_css' ), $priority ); |
||
| 167 | } |
||
| 296 |