| Conditions | 11 |
| Paths | 576 |
| Total Lines | 71 |
| Code Lines | 48 |
| 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 | $count_b = 1; |
||
| 56 | if ( is_multisite() ) { |
||
| 57 | if ( function_exists( 'get_blog_count' ) ) { |
||
| 58 | $count_b = get_blog_count(); |
||
| 59 | } else { |
||
| 60 | $count_b = 'Not Set'; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 64 | $data['php_version'] = phpversion(); |
||
| 65 | $data['mi_version'] = MONSTERINSIGHTS_VERSION; |
||
| 66 | $data['wp_version'] = get_bloginfo( 'version' ); |
||
| 67 | $data['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : ''; |
||
| 68 | $data['over_time'] = get_option( 'monsterinsights_over_time', array() ); |
||
| 69 | $data['multisite'] = is_multisite(); |
||
| 70 | $data['url'] = home_url(); |
||
| 71 | $data['themename'] = $theme_data->Name; |
||
| 72 | $data['themeversion'] = $theme_data->Version; |
||
| 73 | $data['email'] = get_bloginfo( 'admin_email' ); |
||
| 74 | $data['key'] = monsterinsights_get_license_key(); |
||
| 75 | $data['sas'] = monsterinsights_get_shareasale_id(); |
||
| 76 | $data['settings'] = monsterinsights_get_options(); |
||
| 77 | $data['tracking_mode'] = $tracking_mode; |
||
| 78 | $data['events_mode'] = $events_mode; |
||
| 79 | $data['autoupdate'] = $update_mode; |
||
| 80 | $data['pro'] = (int) monsterinsights_is_pro_version(); |
||
| 81 | $data['sites'] = $count_b; |
||
| 82 | $data['usagetracking'] = get_option( 'monsterinsights_usage_tracking_config', $tracking ); |
||
| 83 | $data['usercount'] = function_exists( 'get_user_count' ) ? get_user_count() : 'Not Set'; |
||
| 84 | |||
| 85 | // Retrieve current plugin information |
||
| 86 | if( ! function_exists( 'get_plugins' ) ) { |
||
| 87 | include ABSPATH . '/wp-admin/includes/plugin.php'; |
||
| 88 | } |
||
| 89 | |||
| 90 | $plugins = array_keys( get_plugins() ); |
||
| 91 | $active_plugins = get_option( 'active_plugins', array() ); |
||
| 92 | |||
| 93 | foreach ( $plugins as $key => $plugin ) { |
||
| 94 | if ( in_array( $plugin, $active_plugins ) ) { |
||
| 95 | // Remove active plugins from list so we can show active and inactive separately |
||
| 96 | unset( $plugins[ $key ] ); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | $data['active_plugins'] = $active_plugins; |
||
| 101 | $data['inactive_plugins'] = $plugins; |
||
| 102 | $data['locale'] = get_locale(); |
||
| 103 | |||
| 104 | return $data; |
||
| 105 | } |
||
| 230 | new MonsterInsights_Tracking(); |