Conditions | 62 |
Paths | > 20000 |
Total Lines | 530 |
Code Lines | 354 |
Lines | 44 |
Ratio | 8.3 % |
Changes | 3 | ||
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 |
||
50 | public function html() { |
||
51 | |||
52 | ?> |
||
53 | <div id="simcal-system-status-report"> |
||
54 | <p><?php _e( 'Please copy and paste this information when contacting support:', 'google-calendar-events' ); ?> </p> |
||
55 | <textarea readonly="readonly" onclick="this.select();"></textarea> |
||
56 | <p><?php _e( 'You can also download your information as a text file to attach, or simply view it below.', 'google-calendar-events' ); ?></p> |
||
57 | <p><a href="#" id="simcal-system-status-report-download" class="button button-primary"><?php _e( 'Download System Report', 'google-calendar-events' ); ?></a></p> |
||
58 | </div> |
||
59 | <hr> |
||
60 | <?php |
||
61 | |||
62 | global $wpdb; |
||
63 | $wp_version = get_bloginfo( 'version' ); |
||
64 | |||
65 | $sections = array(); |
||
66 | $panels = array( |
||
67 | 'wordpress' => array( |
||
68 | 'label' => __( 'WordPress Installation', 'google-calendar-events' ), |
||
69 | 'export' => 'WordPress Installation', |
||
70 | ), |
||
71 | 'theme' => array( |
||
72 | 'label' => __( 'Active Theme', 'google-calendar-events' ), |
||
73 | 'export' => 'Active Theme', |
||
74 | ), |
||
75 | 'plugins' => array( |
||
76 | 'label' => __( 'Active Plugins', 'google-calendar-events' ), |
||
77 | 'export' => 'Active Plugins', |
||
78 | ), |
||
79 | 'server' => array( |
||
80 | 'label' => __( 'Server Environment', 'google-calendar-events' ), |
||
81 | 'export' => 'Server Environment', |
||
82 | ), |
||
83 | 'client' => array( |
||
84 | 'label' => __( 'Client Information', 'google-calendar-events' ), |
||
85 | 'export' => 'Client Information', |
||
86 | ) |
||
87 | ); |
||
88 | |||
89 | /** |
||
90 | * Plugin Information |
||
91 | * ================== |
||
92 | */ |
||
93 | |||
94 | // @todo add report information section for current plugin |
||
95 | |||
96 | /** |
||
97 | * WordPress Installation |
||
98 | * ====================== |
||
99 | */ |
||
100 | |||
101 | $debug_mode = $script_debug = __( 'No', 'google-calendar-events' ); |
||
102 | if ( defined( 'WP_DEBUG' ) ) { |
||
103 | $debug_mode = true === WP_DEBUG ? __( 'Yes', 'google-calendar-events' ) : $debug_mode; |
||
104 | } |
||
105 | if ( defined( 'SCRIPT_DEBUG' ) ) { |
||
106 | $script_debug = true === SCRIPT_DEBUG ? __( 'Yes', 'google-calendar-events' ) : $script_debug; |
||
107 | } |
||
108 | |||
109 | $memory = $this->let_to_num( WP_MEMORY_LIMIT ); |
||
110 | $memory_export = size_format( $memory ); |
||
111 | if ( $memory < 67108864 ) { |
||
112 | $memory = '<mark class="error">' . sprintf( __( '%1$s - It is recomendend to set memory to at least 64MB. See: <a href="%2$s" target="_blank">Increasing memory allocated to PHP</a>', 'google-calendar-events' ), $memory_export, 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) . '</mark>'; |
||
113 | } else { |
||
114 | $memory = '<mark class="ok">' . $memory_export . '</mark>'; |
||
115 | } |
||
116 | |||
117 | $permalinks = get_option( 'permalink_structure' ); |
||
118 | $permalinks = empty( $permalinks ) ? '/?' : $permalinks; |
||
119 | |||
120 | $is_multisite = is_multisite(); |
||
121 | |||
122 | $sections['wordpress'] = array( |
||
123 | 'name' => array( |
||
124 | 'label' => __( 'Site Name', 'google-calendar-events' ), |
||
125 | 'label_export' => 'Site Name', |
||
126 | 'result' => get_bloginfo( 'name' ), |
||
127 | ), |
||
128 | 'home_url' => array( |
||
129 | 'label' => __( 'Home URL', 'google-calendar-events' ), |
||
130 | 'label_export' => 'Home URL', |
||
131 | 'result' => home_url(), |
||
132 | ), |
||
133 | 'site_url' => array( |
||
134 | 'label' => __( 'Site URL', 'google-calendar-events' ), |
||
135 | 'label_export' => 'Site URL', |
||
136 | 'result' => site_url(), |
||
137 | ), |
||
138 | 'version' => array( |
||
139 | 'label' => __( 'Version', 'google-calendar-events' ), |
||
140 | 'label_export' => 'Version', |
||
141 | 'result' => $wp_version, |
||
142 | ), |
||
143 | 'locale' => array( |
||
144 | 'label' => __( 'Locale', 'google-calendar-events' ), |
||
145 | 'label_export' => 'Locale', |
||
146 | 'result' => get_locale(), |
||
147 | ), |
||
148 | 'wp_timezone' => array( |
||
149 | 'label' => __( 'Timezone', 'google-calendar-events' ), |
||
150 | 'label_export' => 'Timezone', |
||
151 | 'result' => simcal_get_wp_timezone(), |
||
152 | ), |
||
153 | 'multisite' => array( |
||
154 | 'label' => __( 'Multisite', 'google-calendar-events' ), |
||
155 | 'label_export' => 'Multisite', |
||
156 | 'result' => $is_multisite ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
||
157 | 'result_export' => $is_multisite ? 'Yes' : 'No' |
||
158 | ), |
||
159 | 'permalink' => array( |
||
160 | 'label' => __( 'Permalinks', 'google-calendar-events' ), |
||
161 | 'label_export' => 'Permalinks', |
||
162 | 'result' => '<code>' . $permalinks . '</code>', |
||
163 | 'result_export' => $permalinks, |
||
164 | ), |
||
165 | 'memory_limit' => array( |
||
166 | 'label' => 'WP Memory Limit', |
||
167 | 'result' => $memory, |
||
168 | 'result_export' => $memory_export, |
||
169 | ), |
||
170 | 'debug_mode' => array( |
||
171 | 'label' => 'WP Debug Mode', |
||
172 | 'result' => $debug_mode, |
||
173 | ), |
||
174 | 'script_debug' => array( |
||
175 | 'label' => 'Script Debug', |
||
176 | 'result' => $script_debug, |
||
177 | ), |
||
178 | ); |
||
179 | |||
180 | /** |
||
181 | * Active Theme |
||
182 | * ============ |
||
183 | */ |
||
184 | |||
185 | include_once ABSPATH . 'wp-admin/includes/theme-install.php'; |
||
186 | |||
187 | if ( version_compare( $wp_version, '3.4', '<' ) ) { |
||
188 | $active_theme = get_theme_data( get_stylesheet_directory() . '/style.css' ); |
||
189 | $theme_name = '<a href="' . $active_theme['URI'] . '" target="_blank">' . $active_theme['Name'] . '</a>'; |
||
190 | $theme_version = $active_theme['Version']; |
||
191 | $theme_author = '<a href="' . $active_theme['AuthorURI'] . '" target="_blank">' . $active_theme['Author'] . '</a>'; |
||
192 | $theme_export = $active_theme['Name'] . ' - ' . $theme_version; |
||
193 | } else { |
||
194 | $active_theme = wp_get_theme(); |
||
195 | $theme_name = '<a href="' . $active_theme->ThemeURI . '" target="_blank">' . $active_theme->Name . '</a>'; |
||
196 | $theme_version = $active_theme->Version; |
||
197 | $theme_author = $active_theme->Author; |
||
198 | $theme_export = $active_theme->Name . ' - ' . $theme_version; |
||
199 | } |
||
200 | |||
201 | $theme_update_version = $theme_version; |
||
202 | |||
203 | $api = themes_api( 'theme_information', array( |
||
204 | 'slug' => get_template(), |
||
205 | 'fields' => array( 'sections' => false, 'tags' => false ), |
||
206 | ) ); |
||
207 | if ( $api && ! is_wp_error( $api ) ) { |
||
208 | $theme_update_version = $api->version; |
||
209 | } |
||
210 | |||
211 | View Code Duplication | if ( version_compare( $theme_version, $theme_update_version, '<' ) ) { |
|
212 | $theme_version = '<mark class="error">' . $theme_version . ' (' . sprintf( __( '%s is available', 'google-calendar-events' ), esc_html( $theme_update_version ) ) . ')</mark>'; |
||
213 | } else { |
||
214 | $theme_version = '<mark class="ok">' . $theme_version . '</mark>'; |
||
215 | } |
||
216 | |||
217 | $theme = '<dl>'; |
||
218 | $theme .= '<dt>' . __( 'Name', 'google-calendar-events' ) . '</dt>'; |
||
219 | $theme .= '<dd>' . $theme_name . '</dd>'; |
||
220 | $theme .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>'; |
||
221 | $theme .= '<dd>' . $theme_author . '</dd>'; |
||
222 | $theme .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>'; |
||
223 | $theme .= '<dd>' . $theme_version . '</dd>'; |
||
224 | $theme .= '</dl>'; |
||
225 | |||
226 | $is_child_theme = is_child_theme(); |
||
227 | $parent_theme = $parent_theme_export = '-'; |
||
228 | |||
229 | if ( $is_child_theme ) { |
||
230 | if ( version_compare( $wp_version, '3.4', '<' ) ) { |
||
231 | |||
232 | $parent_theme = $parent_theme_export = $active_theme['Template']; |
||
233 | |||
234 | } else { |
||
235 | |||
236 | $parent = wp_get_theme( $active_theme->Template ); |
||
237 | $parent_theme = '<dl>'; |
||
238 | $parent_theme .= '<dt>' . __( 'Name', 'google-calendar-events' ) . '</dt>'; |
||
239 | $parent_theme .= '<dd>' . $parent->Name . '</dd>'; |
||
240 | $parent_theme .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>'; |
||
241 | $parent_theme .= '<dd>' . $parent->Author . '</dd>'; |
||
242 | $parent_theme .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>'; |
||
243 | $parent_theme .= '<dd>' . $parent->Version . '</dd>'; |
||
244 | $parent_theme .= '</dl>'; |
||
245 | |||
246 | $parent_theme_export = strip_tags( $parent->Name ) . ' - ' . $parent->Version; |
||
247 | } |
||
248 | } |
||
249 | |||
250 | $sections['theme'] = array( |
||
251 | 'theme' => array( |
||
252 | 'label' => __( 'Theme Information', 'google-calendar-events' ), |
||
253 | 'label_export' => 'Theme', |
||
254 | 'result' => $theme, |
||
255 | 'result_export' => $theme_export, |
||
256 | ), |
||
257 | 'theme_child' => array( |
||
258 | 'label' => __( 'Child Theme', 'google-calendar-events' ), |
||
259 | 'label_export' => 'Child Theme', |
||
260 | 'result' => $is_child_theme ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
||
261 | 'result_export' => $is_child_theme ? 'Yes' : 'No', |
||
262 | ), |
||
263 | 'theme_parent' => array( |
||
264 | 'label' => __( 'Parent Theme', 'google-calendar-events' ), |
||
265 | 'label_export' => 'Parent Theme', |
||
266 | 'result' => $parent_theme, |
||
267 | 'result_export' => $parent_theme_export, |
||
268 | ), |
||
269 | ); |
||
270 | |||
271 | /** |
||
272 | * Active Plugins |
||
273 | * ============== |
||
274 | */ |
||
275 | |||
276 | include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
||
277 | |||
278 | $active_plugins = (array) get_option( 'active_plugins', array() ); |
||
279 | if ( is_multisite() ) { |
||
280 | $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) ); |
||
281 | } |
||
282 | |||
283 | foreach ( $active_plugins as $plugin ) { |
||
284 | |||
285 | $plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
||
286 | |||
287 | if ( ! empty( $plugin_data['Name'] ) ) { |
||
288 | |||
289 | $plugin_name = $plugin_data['Title']; |
||
290 | $plugin_author = $plugin_data['Author']; |
||
291 | $plugin_version = $plugin_update_version = $plugin_data['Version']; |
||
292 | |||
293 | // Afraid that querying many plugins may risk a timeout. |
||
294 | if ( count( $active_plugins ) <= 10 ) { |
||
295 | $api = plugins_api( 'plugin_information', array( |
||
296 | 'slug' => $plugin_data['Name'], |
||
297 | 'fields' => array( |
||
298 | 'version' => true, |
||
299 | ), |
||
300 | ) ); |
||
301 | if ( $api && ! is_wp_error( $api ) ) { |
||
302 | if ( ! empty( $api->version ) ) { |
||
303 | $plugin_update_version = $api->version; |
||
304 | View Code Duplication | if ( version_compare( $plugin_version, $plugin_update_version, '<' ) ) { |
|
305 | $plugin_version = '<mark class="error">' . $plugin_version . ' (' . sprintf( __( '%s is available', 'google-calendar-events' ), esc_html( $plugin_update_version ) ) . ')</mark>'; |
||
306 | } else { |
||
307 | $plugin_version = '<mark class="ok">' . $plugin_version . '</mark>'; |
||
308 | } |
||
309 | } |
||
310 | } |
||
311 | } |
||
312 | |||
313 | $plugin = '<dl>'; |
||
314 | $plugin .= '<dt>' . __( 'Author', 'google-calendar-events' ) . '</dt>'; |
||
315 | $plugin .= '<dd>' . $plugin_author . '</dd>'; |
||
316 | $plugin .= '<dt>' . __( 'Version', 'google-calendar-events' ) . '</dt>'; |
||
317 | $plugin .= '<dd>' . $plugin_version . '</dd>'; |
||
318 | $plugin .= '</dl>'; |
||
319 | |||
320 | $sections['plugins'][ sanitize_key( strip_tags( $plugin_name ) ) ] = array( |
||
321 | 'label' => $plugin_name, |
||
322 | 'label_export' => strip_tags( $plugin_data['Title'] ), |
||
323 | 'result' => $plugin, |
||
324 | 'result_export' => $plugin_data['Version'], |
||
325 | ); |
||
326 | } |
||
327 | } |
||
328 | |||
329 | if ( isset( $sections['plugins'] ) ) { |
||
330 | rsort( $sections['plugins'] ); |
||
331 | } |
||
332 | |||
333 | /** |
||
334 | * Server Environment |
||
335 | * ================== |
||
336 | */ |
||
337 | |||
338 | if ( version_compare( PHP_VERSION, '7.0', '<' ) ) { |
||
339 | $php = '<mark>' . PHP_VERSION . ' - ' . |
||
340 | __( 'WordPress.org recommends upgrading to PHP 7 or higher for better security.', 'google-calendar-events' ) . |
||
341 | ' <a href="https://wordpress.org/about/requirements/" target="_blank">' . __( 'Read more.', 'google-calendar-events' ) . '</a>' . |
||
342 | '</mark>'; |
||
343 | } else { |
||
344 | $php = '<mark class="ok">' . PHP_VERSION . '</mark>'; |
||
345 | } |
||
346 | |||
347 | if ( $wpdb->use_mysqli ) { |
||
348 | $mysql = @mysqli_get_server_info( $wpdb->dbh ); |
||
349 | } else { |
||
350 | $mysql = '<mark class="error">' . __( 'Cannot connect to MySQL database.', 'google-calendar-events' ) . '</mark>'; |
||
351 | } |
||
352 | |||
353 | $host = $_SERVER['SERVER_SOFTWARE']; |
||
354 | if ( defined( 'WPE_APIKEY' ) ) { |
||
355 | $host .= ' (WP Engine)'; |
||
356 | } elseif ( defined( 'PAGELYBIN' ) ) { |
||
357 | $host .= ' (Pagely)'; |
||
358 | } |
||
359 | |||
360 | $default_timezone = $server_timezone_export = date_default_timezone_get(); |
||
361 | if ( 'UTC' !== $default_timezone ) { |
||
362 | $server_timezone = '<mark class="error">' . sprintf( __( 'Server default timezone is %s - it should be UTC', 'google-calendar-events' ), $default_timezone ) . '</mark>'; |
||
363 | } else { |
||
364 | $server_timezone = '<mark class="ok">UTC</mark>'; |
||
365 | } |
||
366 | |||
367 | // WP Remote POST test. |
||
368 | $response = wp_safe_remote_post( 'https://www.paypal.com/cgi-bin/webscr', array( |
||
369 | 'timeout' => 60, |
||
370 | 'body' => array( |
||
371 | 'cmd' => '_notify-validate', |
||
372 | ), |
||
373 | ) ); |
||
374 | View Code Duplication | if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
375 | $wp_post_export = 'Yes'; |
||
376 | $wp_post = '<mark class="ok">' . __( 'Yes', 'google-calendar-events' ) . '</mark>'; |
||
377 | } else { |
||
378 | $wp_post_export = 'No'; |
||
379 | $wp_post = '<mark class="error">' . __( 'No', 'google-calendar-events' ); |
||
380 | if ( is_wp_error( $response ) ) { |
||
381 | $error = ' (' . $response->get_error_message() . ')'; |
||
382 | $wp_post .= $error; |
||
383 | $wp_post_export .= $error; |
||
384 | } else { |
||
385 | $error = ' (' . $response['response']['code'] . ')'; |
||
386 | $wp_post .= $error; |
||
387 | $wp_post_export .= $error; |
||
388 | } |
||
389 | $wp_post .= '</mark>'; |
||
390 | } |
||
391 | |||
392 | // WP Remote GET test. |
||
393 | $response = wp_safe_remote_get( get_home_url( '/?p=1' ) ); |
||
394 | View Code Duplication | if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
395 | $wp_get_export = 'Yes'; |
||
396 | $wp_get = '<mark class="ok">' . __( 'Yes', 'google-calendar-events' ) . '</mark>'; |
||
397 | } else { |
||
398 | $wp_get_export = 'No'; |
||
399 | $wp_get = '<mark class="error">' . __( 'No', 'google-calendar-events' ); |
||
400 | if ( is_wp_error( $response ) ) { |
||
401 | $error = ' (' . $response->get_error_message() . ')'; |
||
402 | $wp_get .= $error; |
||
403 | $wp_get_export .= $error; |
||
404 | } else { |
||
405 | $error = ' (' . $response['response']['code'] . ')'; |
||
406 | $wp_get .= $error; |
||
407 | $wp_get_export .= $error; |
||
408 | } |
||
409 | $wp_get .= '</mark>'; |
||
410 | } |
||
411 | |||
412 | $php_memory_limit = ini_get( 'memory_limit' ); |
||
413 | $php_max_upload_filesize = ini_get( 'upload_max_filesize' ); |
||
414 | $php_post_max_size = ini_get( 'post_max_size' ); |
||
415 | $php_max_execution_time = ini_get( 'max_execution_time' ); |
||
416 | $php_max_input_vars = ini_get( 'max_input_vars' ); |
||
417 | |||
418 | $curl_info = ''; |
||
419 | |||
420 | if ( function_exists( 'curl_version' ) ) { |
||
421 | $curl_info = curl_version(); |
||
422 | } |
||
423 | |||
424 | $sections['server'] = array( |
||
425 | 'host' => array( |
||
426 | 'label' => __( 'Web Server', 'google-calendar-events' ), |
||
427 | 'label_export' => 'Web Server', |
||
428 | 'result' => $host, |
||
429 | ), |
||
430 | 'php_version' => array( |
||
431 | 'label' => __( 'PHP Version', 'google-calendar-events' ), |
||
432 | 'label_export' => 'PHP Version', |
||
433 | 'result' => $php, |
||
434 | 'result_export' => PHP_VERSION, |
||
435 | ), |
||
436 | 'mysql_version' => array( |
||
437 | 'label' => __( 'MySQL Version', 'google-calendar-events' ), |
||
438 | 'label_export' => 'MySQL Version', |
||
439 | 'result' => version_compare( $mysql, '5.5', '>' ) ? '<mark class="ok">' . $mysql . '</mark>' : $mysql, |
||
440 | 'result_export' => $mysql, |
||
441 | ), |
||
442 | 'server_timezone' => array( |
||
443 | 'label' => __( 'Server Timezone', 'google-calendar-events' ), |
||
444 | 'label_export' => 'Server Timezone', |
||
445 | 'result' => $server_timezone, |
||
446 | 'result_export' => $server_timezone_export, |
||
447 | ), |
||
448 | 'display_errors' => array( |
||
449 | 'label' => 'Display Errors', |
||
450 | 'result' => ( ini_get( 'display_errors' ) ) ? __( 'Yes', 'google-calendar-events' ) . ' (' . ini_get( 'display_errors' ) . ')' : '-', |
||
451 | 'result_export' => ( ini_get( 'display_errors' ) ) ? 'Yes' : 'No', |
||
452 | ), |
||
453 | 'php_memory_limit' => array( |
||
454 | 'label' => 'Memory Limit', |
||
455 | 'result' => $php_memory_limit ? $php_memory_limit : '-', |
||
456 | ), |
||
457 | 'upload_max_filesize' => array( |
||
458 | 'label' => 'Upload Max Filesize', |
||
459 | 'result' => $php_max_upload_filesize ? $php_max_upload_filesize : '-', |
||
460 | ), |
||
461 | 'post_max_size' => array( |
||
462 | 'label' => 'Post Max Size', |
||
463 | 'result' => $php_post_max_size ? $php_post_max_size : '-', |
||
464 | ), |
||
465 | 'max_execution_time' => array( |
||
466 | 'label' => 'Max Execution Time', |
||
467 | 'result' => $php_max_execution_time ? $php_max_execution_time : '-', |
||
468 | ), |
||
469 | 'max_input_vars' => array( |
||
470 | 'label' => 'Max Input Vars', |
||
471 | 'result' => $php_max_input_vars ? $php_max_input_vars : '-', |
||
472 | ), |
||
473 | 'fsockopen' => array( |
||
474 | 'label' => 'fsockopen', |
||
475 | 'result' => function_exists( 'fsockopen' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
||
476 | 'result_export' => function_exists( 'fsockopen' ) ? 'Yes' : 'No', |
||
477 | ), |
||
478 | 'curl_init' => array( |
||
479 | 'label' => 'cURL', |
||
480 | 'result' => ! empty( $curl_info ) ? $curl_info['version'] . ', ' . $curl_info['ssl_version'] : __( 'No version found.', 'google-calendar-events' ), |
||
481 | 'result_export' => ! empty( $curl_info ) ? $curl_info['version'] . ', ' . $curl_info['ssl_version'] : 'No version found.', |
||
482 | ), |
||
483 | 'soap' => array( |
||
484 | 'label' => 'SOAP', |
||
485 | 'result' => class_exists( 'SoapClient' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
||
486 | 'result_export' => class_exists( 'SoapClient' ) ? 'Yes' : 'No', |
||
487 | ), |
||
488 | 'suhosin' => array( |
||
489 | 'label' => 'SUHOSIN', |
||
490 | 'result' => extension_loaded( 'suhosin' ) ? __( 'Yes', 'google-calendar-events' ) : __( 'No', 'google-calendar-events' ), |
||
491 | 'result_export' => extension_loaded( 'suhosin' ) ? 'Yes' : 'No', |
||
492 | ), |
||
493 | 'wp_remote_post' => array( |
||
494 | 'label' => 'WP Remote POST', |
||
495 | 'result' => $wp_post, |
||
496 | 'result_export' => $wp_post_export, |
||
497 | ), |
||
498 | 'wp_remote_get' => array( |
||
499 | 'label' => 'WP Remote GET', |
||
500 | 'result' => $wp_get, |
||
501 | 'result_export' => $wp_get_export, |
||
502 | ), |
||
503 | ); |
||
504 | |||
505 | /** |
||
506 | * Client Information |
||
507 | * ================== |
||
508 | */ |
||
509 | |||
510 | $user_client = new \SimpleCalendar\Browser(); |
||
511 | |||
512 | $browser = '<dl>'; |
||
513 | $browser .= '<dt>' . __( 'Name:', 'google-calendar-events' ) . '</dt>'; |
||
514 | $browser .= '<dd>' . $user_client->getBrowser() . '</dd>'; |
||
515 | $browser .= '<dt>' . __( 'Version:', 'google-calendar-events' ) . '</dt>'; |
||
516 | $browser .= '<dd>' . $user_client->getVersion() . '</dd>'; |
||
517 | $browser .= '<dt>' . __( 'User Agent:', 'google-calendar-events' ) . '</dt>'; |
||
518 | $browser .= '<dd>' . $user_client->getUserAgent() . '</dd>'; |
||
519 | $browser .= '<dt>' . __( 'Platform:', 'google-calendar-events' ) . '</dt>'; |
||
520 | $browser .= '<dd>' . $user_client->getPlatform() . '</dd>'; |
||
521 | $browser .= '</dl>'; |
||
522 | |||
523 | $browser_export = $user_client->getBrowser() . ' ' . $user_client->getVersion() . ' (' . $user_client->getPlatform() . ')'; |
||
524 | |||
525 | $sections['client'] = array( |
||
526 | 'user_ip' => array( |
||
527 | 'label' => __( 'IP Address', 'google-calendar-events' ), |
||
528 | 'label_export' => 'IP Address', |
||
529 | 'result' => $_SERVER['SERVER_ADDR'], |
||
530 | ), |
||
531 | 'browser' => array( |
||
532 | 'label' => __( 'Browser', 'google-calendar-events' ), |
||
533 | 'result' => $browser, |
||
534 | 'result_export' => $browser_export, |
||
535 | ) |
||
536 | ); |
||
537 | |||
538 | /** |
||
539 | * Final Output |
||
540 | * ============ |
||
541 | */ |
||
542 | |||
543 | $panels = apply_filters( 'simcal_system_status_report_panels', $panels ); |
||
544 | $sections = apply_filters( 'simcal_system_status_report_sections', $sections ); |
||
545 | |||
546 | foreach ( $panels as $panel => $v ) : |
||
547 | |||
548 | if ( isset( $sections[ $panel ] ) ) : |
||
549 | |||
550 | ?> |
||
551 | <table class="widefat simcal-system-status-report-panel"> |
||
552 | <thead class="<?php echo $panel; ?>"> |
||
553 | <tr> |
||
554 | <th colspan="3" data-export="<?php echo $v['export']; ?>"><?php echo $v['label']; ?></th> |
||
555 | </tr> |
||
556 | </thead> |
||
557 | <tbody> |
||
558 | <?php foreach ( $sections[ $panel ] as $row => $cell ) : ?> |
||
559 | <tr> |
||
560 | <?php |
||
561 | $label_export = isset( $cell['label_export'] ) ? $cell['label_export'] : $cell['label']; |
||
562 | $result_export = isset( $cell['result_export'] ) ? $cell['result_export'] : $cell['result']; |
||
563 | ?> |
||
564 | <td class="tooltip"><?php echo isset( $cell['tooltip'] ) ? ' <i class="simcal-icon-help simcal-help-tip" data-tip="' . $cell['tooltip'] . '"></i> ' : ''; ?></td> |
||
565 | <td class="label" data-export="<?php echo trim( $label_export ); ?>"><?php echo $cell['label']; ?></td> |
||
566 | <td class="result" data-export="<?php echo trim( $result_export ); ?>"><?php echo $cell['result']; ?></td> |
||
567 | </tr> |
||
568 | <?php endforeach; ?> |
||
569 | </tbody> |
||
570 | </table> |
||
571 | <?php |
||
572 | |||
573 | endif; |
||
574 | |||
575 | endforeach; |
||
576 | |||
577 | $this->inline_scripts(); |
||
578 | |||
579 | } |
||
580 | |||
714 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.