PluginProbe
Plugin Detective – Troubleshooting Conflicts / 1.2.24
Plugin Detective – Troubleshooting Conflicts v1.2.24
1.2.33 1.2.32 1.2.31 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2 1.2.1 1.2.10 1.2.12 1.2.13 1.2.14 1.2.16 1.2.19 1.2.20 1.2.22 1.2.23 1.2.24 1.2.25 All 53 releases
plugin-detective / troubleshoot / includes / class-installed.php

class-installed.php in Plugin Detective – Troubleshooting Conflicts 1.2.24, at troubleshoot/includes/class-installed.php

162 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Troubleshoot Installed.
4 *
5 * @since 0.0.0
6 * @package Troubleshoot
7 */
8
9 /**
10 * Troubleshoot Installed.
11 *
12 * @since 0.0.0
13 */
14 class PDT_Installed {
15 /**
16 * Parent plugin class.
17 *
18 * @since 0.0.0
19 *
20 * @var Troubleshoot
21 */
22 protected $plugin = null;
23
24 /**
25 * Constructor.
26 *
27 * @since 0.0.0
28 *
29 * @param Troubleshoot $plugin Main plugin object.
30 */
31 public function __construct( $plugin ) {
32 $this->plugin = $plugin;
33 $this->hooks();
34 }
35
36 /**
37 * Initiate our hooks.
38 *
39 * @since 0.0.0
40 */
41 public function hooks() {
42
43 }
44
45 public function get_all( $params=array() ) {
46 $data = array(
47 'core' => $this->get_core(),
48 'plugins' => $this->get_plugins(),
49 'themes' => $this->get_themes(),
50 );
51
52 if ( !empty( $data['plugins']['plugin-detective'] ) ) {
53 unset( $data['plugins']['plugin-detective'] );
54 }
55
56 return $data;
57 }
58
59 public function get_all_active( $params=array() ) {
60 $data = $this->get_all();
61 $data['plugins'] = array_filter( $data['plugins'], array( $this, 'filter_active' ) );
62 $data['themes'] = array_filter( $data['themes'], array( $this, 'filter_active' ) );
63
64 return $data;
65 }
66
67 public function filter_active( $item ) {
68 if ( empty( $item['Active'] ) ) {
69 return false;
70 }
71
72 return true;
73 }
74
75 public function get_core( $params=array() ) {
76 global $wp_version;
77 global $wp_db_version;
78 $core = array(
79 'version' => $wp_version,
80 'db_version' => $wp_db_version,
81 'latest' => $core_updates_data['updates'][0]->current,
82 'detail' => $core_updates_data['updates'],
83 );
84 if ( version_compare( $core['latest'], $core['version'], '<=' ) ) {
85 //Cases where the latest is actually older than installed version (caused by caching on some hosts)
86 unset( $core['detail'] );
87 $core['latest'] = $core['version'];
88 }
89
90 return $core;
91 }
92
93 public function get_plugins( $params=array() ) {
94 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
95
96 // Get all plugins
97 $plugins = get_plugins();
98
99 // Get the list of active plugins
100 $active = get_option( 'active_plugins', array() );
101
102
103 // Premium plugins that have adopted the ManageWP API report new plugins by this filter
104 foreach ( (array) $plugins as $plugin_file => $plugin ) {
105 if ( is_plugin_active( $plugin_file ) ) {
106 $plugins[$plugin_file]['Active'] = true;
107 } else {
108 $plugins[$plugin_file]['Active'] = false;
109 }
110
111 $plugins[$plugin_file]['Description'] = htmlspecialchars( $plugins[$plugin_file]['Description'] );
112
113 $plugins[$plugin_file]['plugin_file'] = $plugin_file;
114 if ( empty( $plugins[$plugin_file]['slug'] ) || $plugins[$plugin_file]['slug'] === $plugin_file ) {
115 $plugin_names = explode('/', $plugin_file);
116 $plugins[$plugin_file]['slug'] = $plugin_names[0];
117 }
118 $plugin_slug = $plugins[$plugin_file]['slug'];
119 $plugins[$plugin_file]['icon'] = 'https://ps.w.org/'.$plugin_slug.'/assets/icon-256x256.png';
120 $plugins[$plugin_slug] = $plugins[$plugin_file];
121 unset($plugins[$plugin_file]);
122 if ( is_array( $plugins[$plugin_slug] ) ) {
123 ksort($plugins[$plugin_slug]);
124 }
125 }
126
127 return $plugins;
128 }
129
130 public function get_themes( $params=array() ) {
131 require_once( ABSPATH . '/wp-admin/includes/theme.php' );
132 // Get all themes
133 if ( function_exists( 'wp_get_themes' ) ) {
134 $themes = wp_get_themes();
135 }
136
137 // Get the active theme
138 $active_theme = wp_get_theme();
139 foreach ( (array) $themes as $key => $theme ) {
140 // WordPress 3.4+
141 if ( is_object( $theme ) && is_a( $theme, 'WP_Theme' ) ) {
142 /* @var $theme WP_Theme */
143 $theme_array = array(
144 'Name' => $theme->get( 'Name' ),
145 'Active' => ( $active_theme->get_stylesheet() == $theme->get_stylesheet() ),
146 'Template' => $theme->get_template(),
147 'Stylesheet' => $theme->get_stylesheet(),
148 'Screenshot' => $theme->get_screenshot(),
149 'AuthorURI' => $theme->get( 'AuthorURI' ),
150 'Author' => $theme->get( 'Author' ),
151 'Version' => $theme->get( 'Version' ),
152 'ThemeURI' => $theme->get( 'ThemeURI' )
153 );
154 $themes_array[$key] = $theme_array;
155 }
156
157 }
158
159 return $themes_array;
160 }
161 }
162