Conditions | 9 |
Paths | 192 |
Total Lines | 62 |
Code Lines | 42 |
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 |
||
34 | private function get_data() { |
||
35 | $data = array(); |
||
36 | |||
37 | // Retrieve current theme info |
||
38 | $theme_data = wp_get_theme(); |
||
39 | $tracking_mode = monsterinsights_get_option( 'tracking_mode', 'analytics' ); |
||
40 | $events_mode = monsterinsights_get_option( 'events_mode', 'none' ); |
||
41 | $update_mode = monsterinsights_get_option( 'automatic_updates', false ); |
||
42 | |||
43 | if ( $tracking_mode === false ) { |
||
|
|||
44 | $tracking_mode = 'analytics'; |
||
45 | } |
||
46 | |||
47 | if ( $events_mode === false ) { |
||
48 | $events_mode = 'none'; |
||
49 | } |
||
50 | |||
51 | if ( $update_mode === false ) { |
||
52 | $update_mode = 'none'; |
||
53 | } |
||
54 | |||
55 | $data['php_version'] = phpversion(); |
||
56 | $data['mi_version'] = MONSTERINSIGHTS_VERSION; |
||
57 | $data['wp_version'] = get_bloginfo( 'version' ); |
||
58 | $data['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : ''; |
||
59 | $data['over_time'] = get_option( 'monsterinsights_over_time', array() ); |
||
60 | $data['multisite'] = is_multisite(); |
||
61 | $data['url'] = home_url(); |
||
62 | $data['themename'] = $theme_data->Name; |
||
63 | $data['themeversion'] = $theme_data->Version; |
||
64 | $data['email'] = get_bloginfo( 'admin_email' ); |
||
65 | $data['key'] = monsterinsights_get_license_key(); |
||
66 | $data['sas'] = monsterinsights_get_shareasale_id(); |
||
67 | $data['settings'] = monsterinsights_get_options(); |
||
68 | $data['tracking_mode'] = $tracking_mode; |
||
69 | $data['events_mode'] = $events_mode; |
||
70 | $data['autoupdate'] = $update_mode; |
||
71 | $data['pro'] = (int) monsterinsights_is_pro_version(); |
||
72 | $data['sites'] = is_multisite() ? (int) get_blog_count() : 1; |
||
73 | $data['usagetracking'] = get_option( 'monsterinsights_usage_tracking_config', $tracking ); |
||
74 | $data['usercount'] = get_user_count(); |
||
75 | |||
76 | // Retrieve current plugin information |
||
77 | if( ! function_exists( 'get_plugins' ) ) { |
||
78 | include ABSPATH . '/wp-admin/includes/plugin.php'; |
||
79 | } |
||
80 | |||
81 | $plugins = array_keys( get_plugins() ); |
||
82 | $active_plugins = get_option( 'active_plugins', array() ); |
||
83 | |||
84 | foreach ( $plugins as $key => $plugin ) { |
||
85 | if ( in_array( $plugin, $active_plugins ) ) { |
||
86 | // Remove active plugins from list so we can show active and inactive separately |
||
87 | unset( $plugins[ $key ] ); |
||
88 | } |
||
89 | } |
||
90 | |||
91 | $data['active_plugins'] = $active_plugins; |
||
92 | $data['inactive_plugins'] = $plugins; |
||
93 | $data['locale'] = get_locale(); |
||
94 | |||
95 | return $data; |
||
96 | } |
||
221 | new MonsterInsights_Tracking(); |