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