| Conditions | 7 |
| Paths | 19 |
| Total Lines | 68 |
| 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 |
||
| 162 | public static function enqueue_block_editor_assets() { |
||
| 163 | if ( ! self::should_load_blocks() ) { |
||
| 164 | return; |
||
| 165 | } |
||
| 166 | |||
| 167 | $rtl = is_rtl() ? '.rtl' : ''; |
||
| 168 | |||
| 169 | /** This filter is already documented above */ |
||
| 170 | if ( apply_filters( 'jetpack_gutenberg_cdn', false ) ) { |
||
| 171 | $cdn_base = 'https://s0.wp.com/wp-content/mu-plugins/jetpack/_inc/blocks'; |
||
| 172 | $editor_script = "$cdn_base/editor.js"; |
||
| 173 | $editor_style = "$cdn_base/editor$rtl.css"; |
||
| 174 | |||
| 175 | /** This filter is already documented above */ |
||
| 176 | $version = apply_filters( 'jetpack_gutenberg_cdn_cache_buster', sprintf( '%s-%s', gmdate( 'd-m-Y' ), JETPACK__VERSION ) ); |
||
| 177 | } else { |
||
| 178 | /** This filter is already documented above */ |
||
| 179 | $beta = apply_filters( 'jetpack_beta_blocks', false ) ? '-beta' : ''; |
||
| 180 | $editor_script = plugins_url( "_inc/blocks/editor{$beta}.js", JETPACK__PLUGIN_FILE ); |
||
| 181 | $editor_style = plugins_url( "_inc/blocks/editor{$beta}{$rtl}.css", JETPACK__PLUGIN_FILE ); |
||
| 182 | |||
| 183 | $version = Jetpack::is_development_version() && file_exists( JETPACK__PLUGIN_DIR . '_inc/blocks/editor.js' ) |
||
| 184 | ? filemtime( JETPACK__PLUGIN_DIR . '_inc/blocks/editor.js' ) |
||
| 185 | : JETPACK__VERSION; |
||
| 186 | } |
||
| 187 | |||
| 188 | wp_enqueue_script( |
||
| 189 | 'jetpack-blocks-editor', |
||
| 190 | $editor_script, |
||
| 191 | array( |
||
| 192 | 'lodash', |
||
| 193 | 'wp-api-fetch', |
||
| 194 | 'wp-blocks', |
||
| 195 | 'wp-components', |
||
| 196 | 'wp-compose', |
||
| 197 | 'wp-data', |
||
| 198 | 'wp-date', |
||
| 199 | 'wp-edit-post', |
||
| 200 | 'wp-editor', |
||
| 201 | 'wp-element', |
||
| 202 | 'wp-hooks', |
||
| 203 | 'wp-i18n', |
||
| 204 | 'wp-keycodes', |
||
| 205 | 'wp-plugins', |
||
| 206 | 'wp-token-list', |
||
| 207 | 'wp-url', |
||
| 208 | ), |
||
| 209 | $version, |
||
| 210 | false |
||
| 211 | ); |
||
| 212 | |||
| 213 | wp_localize_script( |
||
| 214 | 'jetpack-blocks-editor', |
||
| 215 | 'Jetpack_Block_Assets_Base_Url', |
||
| 216 | plugins_url( '_inc/blocks/', JETPACK__PLUGIN_FILE ) |
||
| 217 | ); |
||
| 218 | |||
| 219 | $jp_react_page = new Jetpack_React_Page(); |
||
| 220 | wp_localize_script( |
||
| 221 | 'jetpack-blocks-editor', |
||
| 222 | 'Jetpack_Initial_State', |
||
| 223 | $jp_react_page->get_initial_state() |
||
| 224 | ); |
||
| 225 | |||
| 226 | Jetpack::setup_wp_i18n_locale_data(); |
||
| 227 | |||
| 228 | wp_enqueue_style( 'jetpack-blocks-editor', $editor_style, array(), $version ); |
||
| 229 | } |
||
| 230 | } |
||
| 231 |