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