Conditions | 4 |
Paths | 3 |
Total Lines | 64 |
Code Lines | 52 |
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 |
||
186 | protected static function localize( $debug ) { |
||
187 | static $localized = false; |
||
188 | if ( $localized ) { |
||
189 | return; |
||
190 | } |
||
191 | |||
192 | $localized = true; |
||
193 | $l10n = array( |
||
194 | 'fields' => self::$fields, |
||
195 | 'ajax_nonce' => wp_create_nonce( 'ajax_nonce' ), |
||
196 | 'ajaxurl' => admin_url( '/admin-ajax.php' ), |
||
197 | 'script_debug' => $debug, |
||
198 | 'up_arrow_class' => 'dashicons dashicons-arrow-up-alt2', |
||
199 | 'down_arrow_class' => 'dashicons dashicons-arrow-down-alt2', |
||
200 | 'user_can_richedit' => user_can_richedit(), |
||
201 | 'defaults' => array( |
||
202 | 'code_editor' => false, |
||
203 | 'color_picker' => false, |
||
204 | 'date_picker' => array( |
||
205 | 'changeMonth' => true, |
||
206 | 'changeYear' => true, |
||
207 | 'dateFormat' => _x( 'mm/dd/yy', 'Valid formatDate string for jquery-ui datepicker', 'cmb2' ), |
||
208 | 'dayNames' => explode( ',', esc_html__( 'Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday', 'cmb2' ) ), |
||
209 | 'dayNamesMin' => explode( ',', esc_html__( 'Su, Mo, Tu, We, Th, Fr, Sa', 'cmb2' ) ), |
||
210 | 'dayNamesShort' => explode( ',', esc_html__( 'Sun, Mon, Tue, Wed, Thu, Fri, Sat', 'cmb2' ) ), |
||
211 | 'monthNames' => explode( ',', esc_html__( 'January, February, March, April, May, June, July, August, September, October, November, December', 'cmb2' ) ), |
||
212 | 'monthNamesShort' => explode( ',', esc_html__( 'Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec', 'cmb2' ) ), |
||
213 | 'nextText' => esc_html__( 'Next', 'cmb2' ), |
||
214 | 'prevText' => esc_html__( 'Prev', 'cmb2' ), |
||
215 | 'currentText' => esc_html__( 'Today', 'cmb2' ), |
||
216 | 'closeText' => esc_html__( 'Done', 'cmb2' ), |
||
217 | 'clearText' => esc_html__( 'Clear', 'cmb2' ), |
||
218 | ), |
||
219 | 'time_picker' => array( |
||
220 | 'timeOnlyTitle' => esc_html__( 'Choose Time', 'cmb2' ), |
||
221 | 'timeText' => esc_html__( 'Time', 'cmb2' ), |
||
222 | 'hourText' => esc_html__( 'Hour', 'cmb2' ), |
||
223 | 'minuteText' => esc_html__( 'Minute', 'cmb2' ), |
||
224 | 'secondText' => esc_html__( 'Second', 'cmb2' ), |
||
225 | 'currentText' => esc_html__( 'Now', 'cmb2' ), |
||
226 | 'closeText' => esc_html__( 'Done', 'cmb2' ), |
||
227 | 'timeFormat' => _x( 'hh:mm TT', 'Valid formatting string, as per http://trentrichardson.com/examples/timepicker/', 'cmb2' ), |
||
228 | 'controlType' => 'select', |
||
229 | 'stepMinute' => 5, |
||
230 | ), |
||
231 | ), |
||
232 | 'strings' => array( |
||
233 | 'upload_file' => esc_html__( 'Use this file', 'cmb2' ), |
||
234 | 'upload_files' => esc_html__( 'Use these files', 'cmb2' ), |
||
235 | 'remove_image' => esc_html__( 'Remove Image', 'cmb2' ), |
||
236 | 'remove_file' => esc_html__( 'Remove', 'cmb2' ), |
||
237 | 'file' => esc_html__( 'File:', 'cmb2' ), |
||
238 | 'download' => esc_html__( 'Download', 'cmb2' ), |
||
239 | 'check_toggle' => esc_html__( 'Select / Deselect All', 'cmb2' ), |
||
240 | ), |
||
241 | ); |
||
242 | |||
243 | if ( isset( self::$dependencies['code-editor'] ) && function_exists( 'wp_enqueue_code_editor' ) ) { |
||
244 | $l10n['defaults']['code_editor'] = wp_enqueue_code_editor( array( |
||
245 | 'type' => 'text/html', |
||
246 | ) ); |
||
247 | } |
||
248 | |||
249 | wp_localize_script( self::$handle, self::$js_variable, apply_filters( 'cmb2_localized_data', $l10n ) ); |
||
250 | } |
||
253 |