| Conditions | 6 |
| Paths | 11 |
| Total Lines | 59 |
| Lines | 20 |
| Ratio | 33.9 % |
| 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 |
||
| 74 | public static function enqueue_block_editor_assets() { |
||
| 75 | if ( ! self::should_load_blocks() ) { |
||
| 76 | return; |
||
| 77 | } |
||
| 78 | |||
| 79 | $rtl = is_rtl() ? '.rtl' : ''; |
||
| 80 | |||
| 81 | /** This filter is already documented above */ |
||
| 82 | View Code Duplication | if ( apply_filters( 'jetpack_gutenberg_cdn', false ) ) { |
|
| 83 | $cdn_base = 'https://s0.wp.com/wp-content/mu-plugins/jetpack/_inc/blocks'; |
||
| 84 | $editor_script = "$cdn_base/editor.js"; |
||
| 85 | $editor_style = "$cdn_base/editor$rtl.css"; |
||
| 86 | |||
| 87 | /** This filter is already documented above */ |
||
| 88 | $version = apply_filters( 'jetpack_gutenberg_cdn_cache_buster', sprintf( '%s-%s', gmdate( 'd-m-Y' ), JETPACK__VERSION ) ); |
||
| 89 | } else { |
||
| 90 | $editor_script = plugins_url( '_inc/blocks/editor.js', JETPACK__PLUGIN_FILE ); |
||
| 91 | $editor_style = plugins_url( "_inc/blocks/editor$rtl.css", JETPACK__PLUGIN_FILE ); |
||
| 92 | $version = Jetpack::is_development_version() && file_exists( JETPACK__PLUGIN_DIR . '_inc/blocks/editor.js' ) |
||
| 93 | ? filemtime( JETPACK__PLUGIN_DIR . '_inc/blocks/editor.js' ) |
||
| 94 | : JETPACK__VERSION; |
||
| 95 | } |
||
| 96 | |||
| 97 | wp_enqueue_script( |
||
| 98 | 'jetpack-blocks-editor', |
||
| 99 | $editor_script, |
||
| 100 | array( |
||
| 101 | 'lodash', |
||
| 102 | 'wp-api-fetch', |
||
| 103 | 'wp-blocks', |
||
| 104 | 'wp-components', |
||
| 105 | 'wp-compose', |
||
| 106 | 'wp-data', |
||
| 107 | 'wp-date', |
||
| 108 | 'wp-editor', |
||
| 109 | 'wp-element', |
||
| 110 | 'wp-hooks', |
||
| 111 | 'wp-i18n', |
||
| 112 | 'wp-keycodes', |
||
| 113 | 'wp-plugins', |
||
| 114 | 'wp-token-list', |
||
| 115 | 'wp-url', |
||
| 116 | ), |
||
| 117 | $version |
||
| 118 | ); |
||
| 119 | |||
| 120 | wp_localize_script( |
||
| 121 | 'jetpack-blocks-editor', |
||
| 122 | 'Jetpack_Block_Assets_Base_Url', |
||
| 123 | plugins_url( '_inc/blocks/', JETPACK__PLUGIN_FILE ) |
||
| 124 | ); |
||
| 125 | |||
| 126 | wp_add_inline_script( |
||
| 127 | 'wp-i18n', |
||
| 128 | 'wp.i18n.setLocaleData( ' . Jetpack::get_i18n_data_json() . ', \'jetpack\' );' |
||
| 129 | ); |
||
| 130 | |||
| 131 | wp_enqueue_style( 'jetpack-blocks-editor', $editor_style, array(), $version ); |
||
| 132 | } |
||
| 133 | |||
| 159 |