Conditions | 2 |
Paths | 2 |
Total Lines | 56 |
Code Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
107 | protected static function localize( $debug ) { |
||
108 | static $localized = false; |
||
109 | if ( $localized ) { |
||
110 | return; |
||
111 | } |
||
112 | |||
113 | $localized = true; |
||
114 | $l10n = array( |
||
115 | 'ajax_nonce' => wp_create_nonce( 'ajax_nonce' ), |
||
116 | 'ajaxurl' => admin_url( '/admin-ajax.php' ), |
||
117 | 'script_debug' => $debug, |
||
118 | 'up_arrow_class' => 'dashicons dashicons-arrow-up-alt2', |
||
119 | 'down_arrow_class' => 'dashicons dashicons-arrow-down-alt2', |
||
120 | 'defaults' => array( |
||
121 | 'color_picker' => false, |
||
122 | 'date_picker' => array( |
||
123 | 'changeMonth' => true, |
||
124 | 'changeYear' => true, |
||
125 | 'dateFormat' => _x( 'mm/dd/yy', 'Valid formatDate string for jquery-ui datepicker', 'cmb2' ), |
||
126 | 'dayNames' => explode( ',', __( 'Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday', 'cmb2' ) ), |
||
127 | 'dayNamesMin' => explode( ',', __( 'Su, Mo, Tu, We, Th, Fr, Sa', 'cmb2' ) ), |
||
128 | 'dayNamesShort' => explode( ',', __( 'Sun, Mon, Tue, Wed, Thu, Fri, Sat', 'cmb2' ) ), |
||
129 | 'monthNames' => explode( ',', __( 'January, February, March, April, May, June, July, August, September, October, November, December', 'cmb2' ) ), |
||
130 | 'monthNamesShort' => explode( ',', __( 'Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec', 'cmb2' ) ), |
||
131 | 'nextText' => __( 'Next', 'cmb2' ), |
||
132 | 'prevText' => __( 'Prev', 'cmb2' ), |
||
133 | 'currentText' => __( 'Today', 'cmb2' ), |
||
134 | 'closeText' => __( 'Done', 'cmb2' ), |
||
135 | 'clearText' => __( 'Clear', 'cmb2' ), |
||
136 | ), |
||
137 | 'time_picker' => array( |
||
138 | 'timeOnlyTitle' => __( 'Choose Time', 'cmb2' ), |
||
139 | 'timeText' => __( 'Time', 'cmb2' ), |
||
140 | 'hourText' => __( 'Hour', 'cmb2' ), |
||
141 | 'minuteText' => __( 'Minute', 'cmb2' ), |
||
142 | 'secondText' => __( 'Second', 'cmb2' ), |
||
143 | 'currentText' => __( 'Now', 'cmb2' ), |
||
144 | 'closeText' => __( 'Done', 'cmb2' ), |
||
145 | 'timeFormat' => _x( 'hh:mm TT', 'Valid formatting string, as per http://trentrichardson.com/examples/timepicker/', 'cmb2' ), |
||
146 | 'controlType' => 'select', |
||
147 | 'stepMinute' => 5, |
||
148 | ), |
||
149 | ), |
||
150 | 'strings' => array( |
||
151 | 'upload_file' => __( 'Use this file', 'cmb2' ), |
||
152 | 'upload_files' => __( 'Use these files', 'cmb2' ), |
||
153 | 'remove_image' => __( 'Remove Image', 'cmb2' ), |
||
154 | 'remove_file' => __( 'Remove', 'cmb2' ), |
||
155 | 'file' => __( 'File:', 'cmb2' ), |
||
156 | 'download' => __( 'Download', 'cmb2' ), |
||
157 | 'check_toggle' => __( 'Select / Deselect All', 'cmb2' ), |
||
158 | ), |
||
159 | ); |
||
160 | |||
161 | wp_localize_script( self::$handle, self::$js_variable, apply_filters( 'cmb2_localized_data', $l10n ) ); |
||
162 | } |
||
163 | |||
165 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.