Conditions | 14 |
Paths | 64 |
Total Lines | 316 |
Code Lines | 200 |
Lines | 0 |
Ratio | 0 % |
Changes | 6 | ||
Bugs | 1 | Features | 1 |
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 |
||
79 | public function add_settings_meta_calendar_panel( $post_id ) { |
||
80 | |||
81 | ?> |
||
82 | <table id="default-calendar-settings"> |
||
83 | <thead> |
||
84 | <tr><th colspan="2"><?php _e( 'Default calendar', 'google-calendar-events' ); ?></th></tr> |
||
85 | </thead> |
||
86 | <tbody class="simcal-panel-section"> |
||
87 | |||
88 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
||
89 | <th></th> |
||
90 | <td> |
||
91 | <p class="description"> |
||
92 | <?php _e( "Tip: If calendar styles appear to be missing and/or navigation isn't working, try going to", 'google-calendar-events' ); ?> |
||
93 | <a href="<?php echo esc_url( add_query_arg( array ( 'page' => 'simple-calendar_settings', 'tab' => 'advanced' ), admin_url( 'admin.php' ) ) ); ?>"> |
||
94 | <?php _e( 'Calendars → Settings → Advanced', 'google-calendar-events' ); ?></a> |
||
95 | <?php _e( 'and enable', 'google-calendar-events' ); ?> <strong><?php _e( 'Always Enqueue', 'google-calendar-events' ); ?></strong>. |
||
96 | </p> |
||
97 | </td> |
||
98 | </tr> |
||
99 | |||
100 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
||
101 | <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Event bubbles', 'google-calendar-events' ); ?></label></th> |
||
102 | <td> |
||
103 | <?php |
||
104 | |||
105 | $bubbles = get_post_meta( $post_id, '_default_calendar_event_bubble_trigger', true ); |
||
106 | |||
107 | simcal_print_field( array( |
||
108 | 'type' => 'radio', |
||
109 | 'inline' => 'inline', |
||
110 | 'name' => '_default_calendar_event_bubble_trigger', |
||
111 | 'id' => '_default_calendar_event_bubble_trigger', |
||
112 | 'tooltip' => __( 'Open event bubbles in calendar grid by clicking or hovering on event titles. On mobile devices it will always default to tapping.', 'google-calendar-events' ), |
||
113 | 'value' => $bubbles ? $bubbles : 'hover', |
||
114 | 'default' => 'hover', |
||
115 | 'options' => array( |
||
116 | 'click' => __( 'Click', 'google-calendar-events' ), |
||
117 | 'hover' => __( 'Hover', 'google-calendar-events' ), |
||
118 | ), |
||
119 | ) ); |
||
120 | |||
121 | ?> |
||
122 | </td> |
||
123 | </tr> |
||
124 | <tr class="simcal-panel-field simcal-default-calendar-grid" style="display: none;"> |
||
125 | <th><label for="_default_calendar_trim_titles"><?php _e( 'Trim event titles', 'google-calendar-events' ); ?></label></th> |
||
126 | <td> |
||
127 | <?php |
||
128 | |||
129 | $trim = get_post_meta( $post_id, '_default_calendar_trim_titles', true ); |
||
130 | |||
131 | simcal_print_field( array( |
||
132 | 'type' => 'checkbox', |
||
133 | 'name' => '_default_calendar_trim_titles', |
||
134 | 'id' => '_default_calendar_trim_titles', |
||
135 | 'class' => array( |
||
136 | 'simcal-field-show-next', |
||
137 | ), |
||
138 | 'value' => 'yes' == $trim ? 'yes' : 'no', |
||
139 | 'attributes' => array( |
||
140 | 'data-show-next-if-value' => 'yes', |
||
141 | ), |
||
142 | ) ); |
||
143 | |||
144 | simcal_print_field( array( |
||
145 | 'type' => 'standard', |
||
146 | 'subtype' => 'number', |
||
147 | 'name' => '_default_calendar_trim_titles_chars', |
||
148 | 'id' => '_default_calendar_trim_titles_chars', |
||
149 | 'tooltip' => __( 'Shorten event titles in calendar grid to a specified length in characters.', 'google-calendar-events' ), |
||
150 | 'class' => array( |
||
151 | 'simcal-field-tiny', |
||
152 | ), |
||
153 | 'value' => 'yes' == $trim ? strval( max( absint( get_post_meta( $post_id, '_default_calendar_trim_titles_chars', true ) ), 1 ) ) : '20', |
||
154 | 'attributes' => array( |
||
155 | 'min' => '1', |
||
156 | ), |
||
157 | ) ); |
||
158 | |||
159 | ?> |
||
160 | </td> |
||
161 | </tr> |
||
162 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
||
163 | <th><label for="_default_calendar_list_grouped_span"><?php _e( 'Span', 'google-calendar-events' ); ?></label></th> |
||
164 | <td> |
||
165 | <?php |
||
166 | |||
167 | $list_span = max( absint( get_post_meta( $post_id, '_default_calendar_list_range_span', true ) ), 1 ); |
||
168 | |||
169 | simcal_print_field( array( |
||
170 | 'type' => 'standard', |
||
171 | 'subtype' => 'number', |
||
172 | 'name' => '_default_calendar_list_range_span', |
||
173 | 'id' => '_default_calendar_list_range_span', |
||
174 | 'class' => array( |
||
175 | 'simcal-field-tiny', |
||
176 | 'simcal-field-inline', |
||
177 | ), |
||
178 | 'value' => strval( $list_span ), |
||
179 | 'attributes' => array( |
||
180 | 'min' => '1', |
||
181 | ), |
||
182 | ) ); |
||
183 | |||
184 | $list_type = get_post_meta( $post_id, '_default_calendar_list_range_type', true ); |
||
185 | |||
186 | simcal_print_field( array( |
||
187 | 'type' => 'select', |
||
188 | 'name' => '_default_calendar_list_range_type', |
||
189 | 'id' => '_default_calendar_list_range_type', |
||
190 | 'tooltip' => __( 'Range of events to show on each calendar page.', 'google-calendar-events' ), |
||
191 | 'class' => array( |
||
192 | 'simcal-field-inline', |
||
193 | ), |
||
194 | 'value' => $list_type, |
||
195 | 'options' => array( |
||
196 | 'monthly' => __( 'Month(s)', 'google-calendar-events' ), |
||
197 | 'weekly' => __( 'Week(s)', 'google-calendar-events' ), |
||
198 | 'daily' => __( 'Day(s)', 'google-calendar-events' ), |
||
199 | 'events' => __( 'Event(s)', 'google-calendar-events' ), |
||
200 | ), |
||
201 | ) ); |
||
202 | |||
203 | ?> |
||
204 | </td> |
||
205 | </tr> |
||
206 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
||
207 | <th><label for="_default_calendar_list_header"><?php _e( 'Hide header', 'google-calendar-events' ); ?></label></th> |
||
208 | <td> |
||
209 | <?php |
||
210 | |||
211 | $header = get_post_meta( $post_id, '_default_calendar_list_header', true ); |
||
212 | |||
213 | simcal_print_field( array( |
||
214 | 'type' => 'checkbox', |
||
215 | 'name' => '_default_calendar_list_header', |
||
216 | 'id' => '_default_calendar_list_header', |
||
217 | 'tooltip' => __( 'You can use this to hide the month header for this calendar.', 'google-calendar-events' ), |
||
218 | 'value' => 'yes' == $header ? 'yes' : 'no', |
||
219 | ) ); |
||
220 | |||
221 | ?> |
||
222 | </td> |
||
223 | </tr> |
||
224 | <tr class="simcal-panel-field simcal-default-calendar-list" style="display: none;"> |
||
225 | <th><label for="_default_calendar_compact_list"><?php _e( 'Compact list', 'google-calendar-events' ); ?></label></th> |
||
226 | <td> |
||
227 | <?php |
||
228 | |||
229 | $compact = get_post_meta( $post_id, '_default_calendar_compact_list', true ); |
||
230 | |||
231 | simcal_print_field( array( |
||
232 | 'type' => 'checkbox', |
||
233 | 'name' => '_default_calendar_compact_list', |
||
234 | 'id' => '_default_calendar_compact_list', |
||
235 | 'tooltip' => __( 'Make an events list more compact by grouping together events from different days in a single list.', 'google-calendar-events' ), |
||
236 | 'value' => 'yes' == $compact ? 'yes' : 'no', |
||
237 | ) ); |
||
238 | |||
239 | ?> |
||
240 | </td> |
||
241 | </tr> |
||
242 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
||
243 | <th><label for="_default_calendar_limit_visible_events"><?php _e( 'Limit visible events', 'google-calendar-events' ); ?></label></th> |
||
244 | <td> |
||
245 | <?php |
||
246 | |||
247 | $limit = get_post_meta( $post_id, '_default_calendar_limit_visible_events', true ); |
||
248 | |||
249 | simcal_print_field( array( |
||
250 | 'type' => 'checkbox', |
||
251 | 'name' => '_default_calendar_limit_visible_events', |
||
252 | 'id' => '_default_calendar_limit_visible_events', |
||
253 | 'value' => 'yes' == $limit ? 'yes' : 'no', |
||
254 | 'class' => array( |
||
255 | 'simcal-field-show-next', |
||
256 | ), |
||
257 | 'attributes' => array( |
||
258 | 'data-show-next-if-value' => 'yes', |
||
259 | ) |
||
260 | ) ); |
||
261 | |||
262 | $visible_events = absint( get_post_meta( $post_id, '_default_calendar_visible_events', true ) ); |
||
263 | $visible_events = $visible_events > 0 ? $visible_events : 3; |
||
264 | |||
265 | simcal_print_field( array( |
||
266 | 'type' => 'standard', |
||
267 | 'subtype' => 'number', |
||
268 | 'name' => '_default_calendar_visible_events', |
||
269 | 'id' => '_default_calendar_visible_events', |
||
270 | 'tooltip' => __( 'Limit the number of initial visible events on each day to a set maximum.', 'google-calendar-events' ), |
||
271 | 'class' => array( |
||
272 | 'simcal-field-tiny', |
||
273 | ), |
||
274 | 'value' => $visible_events, |
||
275 | 'attributes' => array( |
||
276 | 'min' => '1', |
||
277 | ) |
||
278 | ) ); |
||
279 | |||
280 | ?> |
||
281 | </td> |
||
282 | </tr> |
||
283 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
||
284 | <th><label for="_default_calendar_event_bubbles_action"><?php _e( 'Expand multi-day events', 'google-calendar-events' ); ?></label></th> |
||
285 | <td> |
||
286 | <?php |
||
287 | |||
288 | $post_meta = get_post_meta( $post_id ); |
||
289 | |||
290 | if ( ! is_array( $post_meta ) && ! empty( $post_meta ) ) { |
||
291 | $multi_day_value = 'current_day_only'; |
||
292 | } else { |
||
293 | $multi_day_value = get_post_meta( $post_id, '_default_calendar_expand_multi_day_events', true ); |
||
294 | } |
||
295 | |||
296 | simcal_print_field( array( |
||
297 | 'type' => 'select', |
||
298 | 'name' => '_default_calendar_expand_multi_day_events', |
||
299 | 'id' => '_default_calendar_expand_multi_day_events', |
||
300 | 'tooltip' => __( 'For events spanning multiple days, you can display them on each day of the event, ' . |
||
301 | 'only on the first day of the event, or on all days of the event, but only up to the current day. ' . |
||
302 | 'Third option applies to list views only.', 'google-calendar-events' ), |
||
303 | 'value' => $multi_day_value, |
||
304 | 'options' => array( |
||
305 | 'yes' => __( 'Yes, display on all days of event', 'google-calendar-events' ), |
||
306 | 'no' => __( 'No, display only on first day of event', 'google-calendar-events' ), |
||
307 | 'current_day_only' => __( 'No, display on all days of event up to current day (list view only)', 'google-calendar-events' ), |
||
308 | ), |
||
309 | 'default' => 'current_day_only', |
||
310 | ) ); |
||
311 | |||
312 | ?> |
||
313 | </td> |
||
314 | </tr> |
||
315 | </tbody> |
||
316 | <?php |
||
317 | |||
318 | $settings = get_option( 'simple-calendar_settings_calendars' ); |
||
319 | $default_theme = isset( $settings['default-calendar']['theme'] ) ? $settings['default-calendar']['theme'] : 'light'; |
||
320 | $default_today_color = /*isset( $settings['default-calendar']['today_color'] ) ? $settings['default-calendar']['today_color'] :*/ '#1e73be'; |
||
321 | $default_days_events_color = /*isset( $settings['default-calendar']['days_events_color'] ) ? $settings['default-calendar']['days_events_color'] :*/ '#000000'; |
||
322 | |||
323 | ?> |
||
324 | <tbody class="simcal-panel-section"> |
||
325 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
||
326 | <th><label for="_default_calendar_style_theme"><?php _e( 'Theme', 'google-calendar-events' ); ?></label></th> |
||
327 | <td> |
||
328 | <?php |
||
329 | |||
330 | $saved = get_post_meta( $post_id, '_default_calendar_style_theme', true ); |
||
331 | $value = ! $saved ? $default_theme : $saved; |
||
332 | |||
333 | simcal_print_field( array( |
||
334 | 'type' => 'select', |
||
335 | 'name' => '_default_calendar_style_theme', |
||
336 | 'id' => '_default_calendar_style_theme', |
||
337 | 'value' => $value, |
||
338 | 'tooltip' => __( 'Choose a calendar theme to match your site theme.', 'google-calendar-events' ), |
||
339 | 'options' => array( |
||
340 | 'light' => __( 'Light', 'google-calendar-events' ), |
||
341 | 'dark' => __( 'Dark', 'google-calendar-events' ), |
||
342 | ), |
||
343 | ) ); |
||
344 | |||
345 | ?> |
||
346 | </td> |
||
347 | </tr> |
||
348 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
||
349 | <th><label for="_default_calendar_style_today"><?php _e( 'Today', 'google-calendar-events' ); ?></label></th> |
||
350 | <td> |
||
351 | <?php |
||
352 | |||
353 | $saved = get_post_meta( $post_id, '_default_calendar_style_today', true ); |
||
354 | $value = ! $saved ? $default_today_color : $saved; |
||
355 | |||
356 | simcal_print_field( array( |
||
357 | 'type' => 'standard', |
||
358 | 'subtype' => 'color-picker', |
||
359 | 'name' => '_default_calendar_style_today', |
||
360 | 'id' => '_default_calendar_style_today', |
||
361 | 'value' => $value, |
||
362 | ) ); |
||
363 | |||
364 | ?> |
||
365 | </td> |
||
366 | </tr> |
||
367 | <tr class="simcal-panel-field simcal-default-calendar-grid simcal-default-calendar-list" style="display: none;"> |
||
368 | <th><label for="_default_calendar_style_days_events"><?php _e( 'Days with events', 'google-calendar-events' ); ?></label></th> |
||
369 | <td> |
||
370 | <?php |
||
371 | |||
372 | $saved = get_post_meta( $post_id, '_default_calendar_style_days_events', true ); |
||
373 | $value = ! $saved ? $default_days_events_color : $saved; |
||
374 | |||
375 | simcal_print_field( array( |
||
376 | 'type' => 'standard', |
||
377 | 'subtype' => 'color-picker', |
||
378 | 'name' => '_default_calendar_style_days_events', |
||
379 | 'id' => '_default_calendar_style_days_events', |
||
380 | 'value' => $value, |
||
381 | ) ); |
||
382 | |||
383 | ?> |
||
384 | </td> |
||
385 | </tr> |
||
386 | |||
387 | </tbody> |
||
388 | <?php |
||
389 | |||
390 | ?> |
||
391 | </table> |
||
392 | <?php |
||
393 | |||
394 | } |
||
395 | |||
456 |