PluginProbe
Plugin Report / 1.7
Plugin Report v1.7
2.2.4 trunk 1.1 1.2 1.3 1.4 1.5 1.6 1.6.1 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9 1.9.1 1.9.2 1.9.3 2.0.0 2.0.1 2.0.2 2.1 2.1.1 2.2.0 2.2.1 All 27 releases
← All changes | rt-plugin-report.php +57 -190 2.0.21.7 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * Plugin Name: Plugin Report
4 4 * Plugin URI: https://roytanck.com/?p=277
5 5 * Description: Provides detailed information about currently installed plugins
6 - * Version: 2.0.2
6 + * Version: 1.7
7 7 * Requires at least: 4.6
8 8 * Requires PHP: 5.6
9 9 * Author: Roy Tanck
10 10 * Author URI: https://roytanck.com
@@ -19,11 +19,8 @@
19 19
20 20
21 21 if ( is_admin() && ! class_exists( 'RT_Plugin_Report' ) ) {
22 22
23 - /**
24 - * Plugin Report main class.
25 - */
26 23 class RT_Plugin_Report {
27 24
28 25 // CSS class constants.
29 26 const CSS_CLASS_LOW = 'pr-risk-low';
@@ -30,10 +27,10 @@
30 27 const CSS_CLASS_MED = 'pr-risk-medium';
31 28 const CSS_CLASS_HIGH = 'pr-risk-high';
32 29
33 30 // Other class constants.
34 - const PLUGIN_VERSION = '2.0.1';
35 - const COLS_PER_ROW = 9;
31 + const PLUGIN_VERSION = '1.7';
32 + const COLS_PER_ROW = 7;
36 33 const CACHE_LIFETIME = DAY_IN_SECONDS;
37 34 const CACHE_LIFETIME_NOREPO = WEEK_IN_SECONDS;
38 35
39 36 /**
@@ -130,14 +127,12 @@
130 127 // The report's main table.
131 128 echo '<table id="plugin-report-table" class="wp-list-table widefat fixed striped">';
132 129 echo '<thead>';
133 130 echo '<tr>';
134 - echo '<th data-sort-default>' . esc_html__( 'Name', 'plugin-report' ) . '</th>';
131 + echo '<th>' . esc_html__( 'Name', 'plugin-report' ) . '</th>';
135 132 echo '<th>' . esc_html__( 'Author', 'plugin-report' ) . '</th>';
136 - echo '<th>' . esc_html__( 'Repository', 'plugin-report' ) . '</th>';
137 133 echo '<th>' . esc_html__( 'Activated', 'plugin-report' ) . '</th>';
138 134 echo '<th data-sort-method="none" class="no-sort">' . esc_html__( 'Installed version', 'plugin-report' ) . '</th>';
139 - echo '<th>' . esc_html__( 'Auto-update', 'plugin-report' ) . '</th>';
140 135 echo '<th>' . esc_html__( 'Last update', 'plugin-report' ) . '</th>';
141 136 echo '<th data-sort-method="dotsep">' . esc_html__( 'Tested up to WP version', 'plugin-report' ) . '</th>';
142 137 echo '<th data-sort-method="number">' . esc_html__( 'Rating', 'plugin-report' ) . '</th>';
143 138 echo '</tr>';
@@ -169,10 +164,8 @@
169 164
170 165
171 166 /**
172 167 * Enqueue admin javascript
173 - *
174 - * @param string $hook Screen hook.
175 168 */
176 169 public function enqueue_assets( $hook ) {
177 170 // Check if we're on the right screen.
178 171 if ( 'plugins_page_plugin_report' !== $hook ) {
@@ -179,11 +172,11 @@
179 172 return;
180 173 }
181 174 // Register the plugin's admin js, and require jquery.
182 175 wp_enqueue_script( 'plugin-report-js', plugins_url( '/js/plugin-report.js', __FILE__ ), array( 'jquery', 'plugin-report-tablesort-js' ), self::PLUGIN_VERSION );
183 - wp_enqueue_script( 'plugin-report-tablesort-js', plugins_url( '/js/tablesort.min.js', __FILE__ ), array( 'jquery' ), '5.3' );
184 - wp_enqueue_script( 'plugin-report-tablesort-number-js', plugins_url( '/js/tablesort.number.min.js', __FILE__ ), array( 'plugin-report-tablesort-js' ), '5.3' );
185 - wp_enqueue_script( 'plugin-report-tablesort-dotsep-js', plugins_url( '/js/tablesort.dotsep.min.js', __FILE__ ), array( 'plugin-report-tablesort-js' ), '5.3' );
176 + wp_enqueue_script( 'plugin-report-tablesort-js', plugins_url( '/js/tablesort.min.js', __FILE__ ), array( 'jquery' ), '5.1.0' );
177 + wp_enqueue_script( 'plugin-report-tablesort-number-js', plugins_url( '/js/tablesort.number.min.js', __FILE__ ), array( 'plugin-report-tablesort-js' ), '5.1.0' );
178 + wp_enqueue_script( 'plugin-report-tablesort-dotsep-js', plugins_url( '/js/tablesort.dotsep.min.js', __FILE__ ), array( 'plugin-report-tablesort-js' ), '5.1.0' );
186 179 // Add some variables to the page, to be used by the javascript.
187 180 $slugs = $this->get_plugin_slugs();
188 181 $slugs_str = implode( ',', $slugs );
189 182 $vars = array(
@@ -212,11 +205,9 @@
212 205 }
213 206
214 207
215 208 /**
216 - * Convert a plugin's file path into its slug.
217 - *
218 - * @param string $file Plugin file path.
209 + * Convert a plugin's file path into its slug
219 210 */
220 211 private function get_plugin_slug( $file ) {
221 212 if ( strpos( $file, '/' ) !== false ) {
222 213 $parts = explode( '/', $file );
@@ -271,19 +262,16 @@
271 262
272 263
273 264 /**
274 265 * Gather all the info we can get about a plugin.
275 - * Uses transient caching to avoid doing repo API calls on every page visit.
276 - *
277 - * @param string $slug Plugin slug.
266 + * Uses transient caching to avoid doing repo API calls on every page visit
278 267 */
279 268 private function assemble_plugin_report( $slug ) {
280 269 if ( ! empty( $slug ) ) {
281 - $report = array();
282 - $cache_key = $this->create_cache_key( $slug );
283 - $cache = get_site_transient( $cache_key );
284 - $plugins = get_plugins();
285 - $auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
270 + $report = array();
271 + $cache_key = $this->create_cache_key( $slug );
272 + $cache = get_site_transient( $cache_key );
273 + $plugins = get_plugins();
286 274
287 275 if ( empty( $cache ) ) {
288 276
289 277 // Add the plugin's slug to the report.
@@ -288,39 +276,13 @@
288 276
289 277 // Add the plugin's slug to the report.
290 278 $report['slug'] = $slug;
291 279
292 - // Get the locally available info, and add it to the report.
280 + // Get the locally available info, and add it to the report.
293 281 foreach ( $plugins as $key => $plugin ) {
294 - if ( $this->get_plugin_slug( $key ) === $slug ) {
295 -
296 - // Translate plugin data.
297 - $textdomain = $plugin['TextDomain'];
298 - if ( $textdomain ) {
299 - if ( ! is_textdomain_loaded( $textdomain ) ) {
300 - if ( $plugin['DomainPath'] ) {
301 - load_plugin_textdomain( $textdomain, false, dirname( $key ) . $plugin['DomainPath'] );
302 - } else {
303 - load_plugin_textdomain( $textdomain, false, dirname( $key ) );
304 - }
305 - }
306 - } elseif ( 'hello.php' === basename( $key ) ) {
307 - $textdomain = 'default';
308 - }
309 - if ( $textdomain ) {
310 - foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
311 - // phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
312 - $plugin[ $field ] = translate( $plugin[ $field ], $textdomain );
313 - }
314 - }
315 -
316 - $report['local_info'] = $plugin;
317 - $report['file_path'] = $key;
318 - $report['auto-update'] = in_array( $key, $auto_updates );
319 -
320 - // Change any whitespace to default space.
321 - $report['local_info']['Name'] = preg_replace( '/\s+/u', ' ', $report['local_info']['Name'] );
322 -
282 + if ( $this->get_plugin_slug( $key ) == $slug ) {
283 + $report['local_info'] = $plugin;
284 + $report['file_path'] = $key;
323 285 break;
324 286 }
325 287 }
326 288
@@ -338,29 +300,21 @@
338 300 'compatibility' => true,
339 301 'author' => true,
340 302 ),
341 303 );
304 + $returned_object = plugins_api( 'plugin_information', $args );
342 305
343 - // Check wordpress.org only if "Update URI" plugin header is not set or set to wordpress.org.
344 - $parsed_repo_url = wp_parse_url( $report['local_info']['UpdateURI'] );
345 - $repo_host = isset( $parsed_repo_url['host'] ) ? $parsed_repo_url['host'] : null;
346 - if ( empty( $repo_host ) || strtolower( $repo_host ) === 'w.org' || strtolower( $repo_host ) === 'wordpress.org' ) {
347 - $returned_object = plugins_api( 'plugin_information', $args );
348 - }
349 -
350 306 // Add the repo info to the report.
351 - if ( isset( $returned_object ) ) {
352 - if ( ! is_wp_error( $returned_object ) ) {
353 - $report['repo_info'] = maybe_unserialize( $returned_object );
354 - // Cache the report.
355 - set_site_transient( $cache_key, $report, self::CACHE_LIFETIME );
356 - } else {
357 - // Store the error code and message in the report.
358 - $report['repo_error_code'] = $returned_object->get_error_code();
359 - $report['repo_error_message'] = $returned_object->get_error_message();
360 - // Cache for an extra long time when the plugin is not in the repo.
361 - set_site_transient( $cache_key, $report, self::CACHE_LIFETIME_NOREPO );
362 - }
307 + if ( ! is_wp_error( $returned_object ) ) {
308 + $report['repo_info'] = maybe_unserialize( $returned_object );
309 + // Cache the report.
310 + set_site_transient( $cache_key, $report, self::CACHE_LIFETIME );
311 + } else {
312 + // Store the error code and message in the report.
313 + $report['repo_error_code'] = $returned_object->get_error_code();
314 + $report['repo_error_message'] = $returned_object->get_error_message();
315 + // Cache for an extra long time when the plugin is not in the repo.
316 + set_site_transient( $cache_key, $report, self::CACHE_LIFETIME_NOREPO );
363 317 }
364 318 } else {
365 319 $report = $cache;
366 320 }
@@ -374,24 +328,19 @@
374 328 }
375 329
376 330
377 331 /**
378 - * From a report, generate an HTML table row with relevant data for the plugin.
379 - *
380 - * @param array $report Report of plugin.
332 + * From a report, generate an HTML table row with relevant data for the plugin
381 333 */
382 334 private function render_table_row( $report ) {
383 - // Get the current WP version number.
384 - global $wp_version;
385 335 // Get the latest WP release version number.
386 336 $wp_latest = $this->check_core_updates();
387 337 // Check if the report is valid.
388 - if ( null === $report ) {
338 + if ( $report == null ) {
389 339 $html = $this->render_error_row( esc_html__( 'No plugin data available.', 'plugin-report' ) );
390 340 } else {
391 341 // Start the new table row.
392 342 $html = '<tr class="plugin-report-row-' . $report['slug'] . '">';
393 -
394 343 // Name.
395 344 if ( isset( $report['local_info']['PluginURI'] ) && ! empty( $report['local_info']['PluginURI'] ) ) {
396 345 $html .= '<td><a href="' . $report['local_info']['PluginURI'] . '"><strong>' . $report['local_info']['Name'] . '</strong></a></td>';
397 346 } else {
@@ -396,9 +345,8 @@
396 345 $html .= '<td><a href="' . $report['local_info']['PluginURI'] . '"><strong>' . $report['local_info']['Name'] . '</strong></a></td>';
397 346 } else {
398 347 $html .= '<td><strong>' . $report['local_info']['Name'] . '</strong></td>';
399 348 }
400 -
401 349 // Author.
402 350 if ( isset( $report['local_info']['AuthorURI'] ) && ! empty( $report['local_info']['AuthorURI'] ) ) {
403 351 $html .= '<td><a href="' . $report['local_info']['AuthorURI'] . '">' . $report['local_info']['Author'] . '</a></td>';
404 352 } else {
@@ -403,49 +351,19 @@
403 351 $html .= '<td><a href="' . $report['local_info']['AuthorURI'] . '">' . $report['local_info']['Author'] . '</a></td>';
404 352 } else {
405 353 $html .= '<td>' . $report['local_info']['Author'] . '</td>';
406 354 }
407 -
408 - // Repository.
409 - if ( isset( $report['local_info']['UpdateURI'] ) ) {
410 - // Parse the UpdateURI's value to get the host.
411 - $parsed_repo_url = wp_parse_url( $report['local_info']['UpdateURI'] );
412 - // If the URI is valid, extract the host, otherwise we'll use the header value.
413 - $repo_host = isset( $parsed_repo_url['host'] ) ? $parsed_repo_url['host'] : $report['local_info']['UpdateURI'];
414 - // Check if the plugin is supposed to be hosted on wp.org.
415 - if ( empty( $repo_host ) || strtolower( $repo_host ) === 'w.org' || strtolower( $repo_host ) === 'wordpress.org' ) {
416 - // Plugin should be available on wp.org, check if we got a 'not found' error.
417 - if ( isset( $report['repo_error_code'] ) && $report['repo_error_code'] === 'plugins_api_failed' ) {
418 - // Plugin is not available in the wp.org repo.
419 - $html .= '<td class="' . self::CSS_CLASS_HIGH . '">' . __( 'wordpress.org, plugin not found', 'plugin-report' ) . '</td>';
420 - } else {
421 - // Plugin is available on wp.org.
422 - $html .= '<td class="' . self::CSS_CLASS_LOW . '">wordpress.org</td>';
423 - }
424 - } else {
425 - if ( $parsed_repo_url && isset( $parsed_repo_url[ 'host' ] ) ) {
426 - // Update URI is a valid URL, display the host.
427 - $html .= '<td class="' . self::CSS_CLASS_MED . '">' . $repo_host . '</td>';
428 - } else {
429 - // Some other value (like 'false'), so assume updates are disabled.
430 - $html .= '<td class="' . self::CSS_CLASS_MED . '">' . __( 'Updates disabled', 'plugin-report' ) . '</td>';
431 - }
432 - }
433 - } else {
434 - $html .= $this->render_error_cell();
435 - }
436 -
437 355 // Activated.
438 - $active = __( 'Please clear cache to update', 'plugin-report' );
356 + $active = __( 'Please clear cache to update', 'plugin-report' );
439 357 $css_class = self::CSS_CLASS_MED;
440 358 if ( is_multisite() ) {
441 359 $activation_status = $this->get_multisite_activation( $report['file_path'] );
442 360 if ( true === $activation_status['network'] ) {
443 361 $css_class = self::CSS_CLASS_LOW;
444 - $html .= '<td class="' . $css_class . '">' . __( 'Network activated', 'plugin-report' ) . '</td>';
362 + $html .= '<td class="' . $css_class . '">' . __( 'Network activated', 'plugin-report' ) . '</td>';
445 363 } else {
446 364 $css_class = ( $activation_status['active'] > 0 ) ? self::CSS_CLASS_LOW : self::CSS_CLASS_HIGH;
447 - $html .= '<td class="' . $css_class . '">' . $activation_status['active'] . '/' . $activation_status['sites'] . '</td>';
365 + $html .= '<td class="' . $css_class . '">' . $activation_status['active'] . '/' . $activation_status['sites'] . '</td>';
448 366 }
449 367 } else {
450 368 if ( isset( $report['file_path'] ) ) {
451 369 $active = is_plugin_active( $report['file_path'] ) ? __( 'Yes', 'plugin-report' ) : __( 'No', 'plugin-report' );
@@ -452,31 +370,31 @@
452 370 $css_class = is_plugin_active( $report['file_path'] ) ? self::CSS_CLASS_LOW : self::CSS_CLASS_HIGH;
453 371 }
454 372 $html .= '<td class="' . $css_class . '">' . $active . '</td>';
455 373 }
456 -
457 374 // Installed / available version.
458 375 if ( isset( $report['repo_info'] ) ) {
459 376 $css_class = $this->get_version_risk_classname( $report['local_info']['Version'], $report['repo_info']->version );
460 - $html .= '<td class="' . $css_class . '">';
461 - $html .= $report['local_info']['Version'];
462 - if ( $report['local_info']['Version'] !== $report['repo_info']->version ) {
377 + $html .= '<td class="' . $css_class . '">';
378 + $html .= $report['local_info']['Version'];
379 + if ( $report['local_info']['Version'] != $report['repo_info']->version ) {
463 380 // Any platform upgrades needed?
381 + global $wp_version;
464 382 $needs_php_upgrade = isset( $report['repo_info']->requires_php ) ? version_compare( phpversion(), $report['repo_info']->requires_php, '<' ) : false;
465 383 $needs_wp_upgrade = isset( $report['repo_info']->requires ) ? version_compare( $wp_version, $report['repo_info']->requires, '<' ) : false;
466 384 // Create the additional message.
467 385 if ( $needs_wp_upgrade && $needs_php_upgrade ) {
468 386 /* translators: %1$s: Plugin version number, %2$s: WP version number, %3$s: PHP version number */
469 - $html .= ' <span class="pr-additional-info">' . sprintf( esc_html__( '(%1$s available, requires WP %2$s and PHP %3$s)', 'plugin-report' ), $report['repo_info']->version, $report['repo_info']->requires, $report['repo_info']->requires_php ) . '</span>';
387 + $html .= ' <span class="pr-additional-info">' . sprintf( esc_html__( '(%1$s available, requires WP %2$s and PHP %3$s)', 'plugin-report'), $report['repo_info']->version, $report['repo_info']->requires, $report['repo_info']->requires_php ) . '</span>';
470 388 } elseif ( $needs_wp_upgrade ) {
471 389 /* translators: %1$s: Plugin version number, %2$s: WP version number. */
472 - $html .= ' <span class="pr-additional-info">' . sprintf( esc_html__( '(%1$s available, requires WP %2$s)', 'plugin-report' ), $report['repo_info']->version, $report['repo_info']->requires ) . '</span>';
390 + $html .= ' <span class="pr-additional-info">' . sprintf( esc_html__( '(%1$s available, requires WP %2$s)', 'plugin-report'), $report['repo_info']->version, $report['repo_info']->requires ) . '</span>';
473 391 } elseif ( $needs_php_upgrade ) {
474 392 /* translators: %1$s: Plugin version number, %2$s: PHP version number. */
475 - $html .= ' <span class="pr-additional-info">' . sprintf( esc_html__( '(%1$s available, requires PHP %2$s)', 'plugin-report' ), $report['repo_info']->version, $report['repo_info']->requires_php ) . '</span>';
393 + $html .= ' <span class="pr-additional-info">' . sprintf( esc_html__( '(%1$s available, requires PHP %2$s)', 'plugin-report'), $report['repo_info']->version, $report['repo_info']->requires_php ) . '</span>';
476 394 } else {
477 395 /* translators: %s: Plugin version number. */
478 - $html .= ' <span class="pr-additional-info">' . sprintf( esc_html__( '(%s available)', 'plugin-report' ), $report['repo_info']->version ) . '</span>';
396 + $html .= ' <span class="pr-additional-info">' . sprintf( esc_html__( '(%s available)', 'plugin-report'), $report['repo_info']->version ) . '</span>';
479 397 }
480 398 }
481 399 $html .= '</td>';
482 400 } else {
@@ -481,22 +399,10 @@
481 399 $html .= '</td>';
482 400 } else {
483 401 $html .= '<td>' . $report['local_info']['Version'] . '</td>';
484 402 }
485 -
486 - // Auto-update.
487 - if ( version_compare( $wp_version, '5.5', '<' ) ) {
488 - $html .= '<td>' . __( 'Requires WordPress 5.5 or higher', 'plugin-report' ) . '</td>';
489 - } else {
490 - if ( isset( $report['auto-update'] ) && $report['auto-update'] ) {
491 - $html .= '<td class="' . self::CSS_CLASS_LOW . '">' . __( 'Enabled', 'plugin-report' ) . '</td>';
492 - } else {
493 - $html .= '<td>' . __( 'Not enabled', 'plugin-report' ) . '</td>';
494 - }
495 - }
496 -
497 403 // Last updates.
498 - if ( isset( $report['repo_info'] ) && isset( $report['repo_info']->last_updated ) ) {
404 + if ( isset( $report['repo_info'] ) ) {
499 405 $time_update = new DateTime( $report['repo_info']->last_updated );
500 406 $time_diff = human_time_diff( $time_update->getTimestamp(), current_time( 'timestamp' ) );
501 407 $css_class = $this->get_timediff_risk_classname( current_time( 'timestamp' ) - $time_update->getTimestamp() );
502 408 $html .= '<td class="' . $css_class . '" data-sort="' . $time_update->getTimestamp() . '">' . $time_diff . '</td>';
@@ -502,19 +408,17 @@
502 408 $html .= '<td class="' . $css_class . '" data-sort="' . $time_update->getTimestamp() . '">' . $time_diff . '</td>';
503 409 } else {
504 410 $html .= $this->render_error_cell();
505 411 }
506 -
507 412 // Tested up to.
508 - if ( isset( $report['repo_info'] ) && isset( $report['repo_info']->tested ) ) {
509 - $css_class = $this->get_version_risk_classname( $report['repo_info']->tested, $wp_latest, true );
510 - $html .= '<td class="' . $css_class . '">' . $report['repo_info']->tested . '</td>';
413 + if ( isset( $report['repo_info'] ) ) {
414 + $css_class = $this->get_version_risk_classname( $report['repo_info']->tested, $wp_latest );
415 + $html .= '<td class="' . $css_class . '">' . $report['repo_info']->tested . '</td>';
511 416 } else {
512 417 $html .= $this->render_error_cell();
513 418 }
514 -
515 419 // Overall user rating.
516 - if ( isset( $report['repo_info'] ) && isset( $report['repo_info']->num_ratings ) && isset( $report['repo_info']->rating ) ) {
420 + if ( isset( $report['repo_info'] ) ) {
517 421 $css_class = ( intval( $report['repo_info']->num_ratings ) > 0 ) ? $this->get_percentage_risk_classname( intval( $report['repo_info']->rating ) ) : '';
518 422 $value_text = ( ( intval( $report['repo_info']->num_ratings ) > 0 ) ? $report['repo_info']->rating . '%' : esc_html__( 'No data available', 'plugin-report' ) );
519 423 $html .= '<td class="' . $css_class . '">' . $value_text . '</td>';
520 424 } else {
@@ -519,9 +423,8 @@
519 423 $html .= '<td class="' . $css_class . '">' . $value_text . '</td>';
520 424 } else {
521 425 $html .= $this->render_error_cell();
522 426 }
523 -
524 427 // Close the new table row.
525 428 $html .= '</tr>';
526 429 }
527 430 return $html;
@@ -528,11 +431,9 @@
528 431 }
529 432
530 433
531 434 /**
532 - * Format an error message as a table row, so we can return it to javascript.
533 - *
534 - * @param string $message Message to be shown.
435 + * Format an error message as a table row, so we can return it to javascript
535 436 */
536 437 private function render_error_row( $message ) {
537 438 return '<tr class="pluginreport-row-error"><td colspan="' . self::COLS_PER_ROW . '">' . $message . '</td></tr>';
538 439 }
@@ -538,11 +439,9 @@
538 439 }
539 440
540 441
541 442 /**
542 - * Format an error message as a table cell, so we can return it to javascript.
543 - *
544 - * @param string $message Message to be shown.
443 + * Format an error message as a table cell, so we can return it to javascript
545 444 */
546 445 private function render_error_cell( $message = null ) {
547 446 if ( ! $message ) {
548 447 $message = esc_html__( 'No data available', 'plugin-report' );
@@ -551,33 +450,11 @@
551 450 }
552 451
553 452
554 453 /**
555 - * Return the version string with all elements beyond the second removed ("5.5.1" -> "5.5").
556 - *
557 - * @param string $version_string Complete version number.
454 + * Figure out what CSS class to use based on current and optimal version numbers
558 455 */
559 - private function get_major_version( $version_string ) {
560 - $parts = explode( '.', $version_string );
561 - array_splice( $parts, 2 );
562 - return implode( '.', $parts );
563 - }
564 -
565 -
566 - /**
567 - * Figure out what CSS class to use based on current and optimal version numbers.
568 - *
569 - * @param string $available Available version.
570 - * @param string $optimal Optimal version.
571 - * @param bool $major_only True to compare only major versions, false otherwise.
572 - */
573 - private function get_version_risk_classname( $available, $optimal, $major_only = false ) {
574 - // Use only the first two elements of the version number if $major_only is set to true.
575 - // This is used for WP version numbers, where point releases are not considered a risk.
576 - if ( $major_only ) {
577 - $available = $this->get_major_version( $available );
578 - $optimal = $this->get_major_version( $optimal );
579 - }
456 + private function get_version_risk_classname( $available, $optimal ) {
580 457 // If the version is equal or higher, indicate low risk.
581 458 if ( version_compare( $available, $optimal, '>=' ) ) {
582 459 return self::CSS_CLASS_LOW;
583 460 }
@@ -586,11 +463,9 @@
586 463 }
587 464
588 465
589 466 /**
590 - * Assess the risk associated with low ratings or poor compatibility feedback, return corresponding CSS class.
591 - *
592 - * @param int $perc Rating percentage.
467 + * Assess the risk associated with low ratings or poor compatibility feedback, return corresponding CSS class
593 468 */
594 469 private function get_percentage_risk_classname( $perc ) {
595 470 if ( $perc < 70 ) {
596 471 return self::CSS_CLASS_HIGH;
@@ -602,11 +477,9 @@
602 477 }
603 478
604 479
605 480 /**
606 - * Assess the risk associated with low ratings or poor compatibility feedback, return corresponding CSS class.
607 - *
608 - * @param string $time_diff Time difference.
481 + * Assess the risk associated with low ratings or poor compatibility feedback, return corresponding CSS class
609 482 */
610 483 private function get_timediff_risk_classname( $time_diff ) {
611 484 $days = $time_diff / ( DAY_IN_SECONDS );
612 485 if ( $days > 365 ) {
@@ -626,13 +499,13 @@
626 499 private function check_core_updates() {
627 500 global $wp_version;
628 501 $update = get_preferred_from_update_core();
629 502 // Bail out of no valid response, or false.
630 - if ( ! $update || false === $update ) {
503 + if ( ! $update || $update == false ) {
631 504 return $wp_version;
632 505 }
633 506 // If latest, return current version number.
634 - if ( 'latest' === $update->response ) {
507 + if ( $update->response == 'latest' ) {
635 508 return $wp_version;
636 509 }
637 510 // Return the preferred update's version number.
638 511 return $update->version;
@@ -639,11 +512,9 @@
639 512 }
640 513
641 514
642 515 /**
643 - * Gather statistics about a plugin's activation on a multisite install.
644 - *
645 - * @param string $path Plugin path.
516 + * Gather statistics about a plugin's activation on a multisite install
646 517 */
647 518 private function get_multisite_activation( $path ) {
648 519 // Create an array to contain the return values.
649 520 $activation_status = array(
@@ -656,9 +527,9 @@
656 527 if ( array_key_exists( $path, $network_plugins ) ) {
657 528 $activation_status['network'] = true;
658 529 } else {
659 530 // Get a list of all sites in the multisite install.
660 - $args = array(
531 + $args = array(
661 532 'number' => 9999,
662 533 'fields' => 'ids',
663 534 );
664 535 $sites = get_sites( $args );
@@ -682,10 +553,8 @@
682 553
683 554
684 555 /**
685 556 * Create a cache key that is unique to the provided plugin slug.
686 - *
687 - * @param string $slug Plugin slug.
688 557 */
689 558 private function create_cache_key( $slug ) {
690 559 // Create a hash for the plugin slug.
691 560 $slug_hash = hash( 'sha256', $slug );
@@ -710,11 +579,9 @@
710 579 }
711 580
712 581
713 582 /**
714 - * Remove the cache item for a single plugin.
715 - *
716 - * @param string $slug Plugin slug.
583 + * Remove the cache item for a single plugin
717 584 */
718 585 private function clear_cache_item( $slug ) {
719 586 if ( isset( $slug ) ) {
720 587 $cache_key = $this->create_cache_key( $slug );