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 -224 2.11.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.1
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.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,31 +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 - // Because the plugin is not found in the wordpress.org repo, check if it exists in SVN.
361 - $report['exists_in_svn'] = $this->check_exists_in_svn( $slug );
362 - // Cache for an extra long time when the plugin is not in the repo.
363 - set_site_transient( $cache_key, $report, self::CACHE_LIFETIME_NOREPO );
364 - }
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 );
365 317 }
366 318 } else {
367 319 $report = $cache;
368 320 }
@@ -376,52 +328,19 @@
376 328 }
377 329
378 330
379 331 /**
380 - * Check if the plugin is present in WordPress's SVN repository.
381 - *
382 - * Function adapted from the 'Enhanced Plugin Admin' plugin by Marios Alexandrou.
383 - * See: https://plugins.trac.wordpress.org/browser/enhanced-plugin-admin/trunk/enhanced-plugin-admin.php
384 - *
385 - * @param string $slug The plugin's slug.
386 - *
387 - * @return boolean True if found, false if not.
332 + * From a report, generate an HTML table row with relevant data for the plugin
388 333 */
389 - private function check_exists_in_svn( $slug ) {
390 - // Attempt to load the plugin's SVN repo page.
391 - $response = wp_remote_get( "http://svn.wp-plugins.org/" . $slug . "/" );
392 - // If the return value was a WP_Error, assume the answer is no.
393 - if( is_wp_error( $response ) ) {
394 - return false;
395 - } else {
396 - // If the returned HTTP code is 200, the page was found, so return true.
397 - $response_code = wp_remote_retrieve_response_code( $response );
398 - if( '200' == $response_code ) {
399 - return true;
400 - }
401 - }
402 - // In all other cases, assume the plugin was not found.
403 - return false;
404 - }
405 -
406 -
407 - /**
408 - * From a report, generate an HTML table row with relevant data for the plugin.
409 - *
410 - * @param array $report Report of plugin.
411 - */
412 334 private function render_table_row( $report ) {
413 - // Get the current WP version number.
414 - global $wp_version;
415 335 // Get the latest WP release version number.
416 336 $wp_latest = $this->check_core_updates();
417 337 // Check if the report is valid.
418 - if ( null === $report ) {
338 + if ( $report == null ) {
419 339 $html = $this->render_error_row( esc_html__( 'No plugin data available.', 'plugin-report' ) );
420 340 } else {
421 341 // Start the new table row.
422 342 $html = '<tr class="plugin-report-row-' . $report['slug'] . '">';
423 -
424 343 // Name.
425 344 if ( isset( $report['local_info']['PluginURI'] ) && ! empty( $report['local_info']['PluginURI'] ) ) {
426 345 $html .= '<td><a href="' . $report['local_info']['PluginURI'] . '"><strong>' . $report['local_info']['Name'] . '</strong></a></td>';
427 346 } else {
@@ -426,9 +345,8 @@
426 345 $html .= '<td><a href="' . $report['local_info']['PluginURI'] . '"><strong>' . $report['local_info']['Name'] . '</strong></a></td>';
427 346 } else {
428 347 $html .= '<td><strong>' . $report['local_info']['Name'] . '</strong></td>';
429 348 }
430 -
431 349 // Author.
432 350 if ( isset( $report['local_info']['AuthorURI'] ) && ! empty( $report['local_info']['AuthorURI'] ) ) {
433 351 $html .= '<td><a href="' . $report['local_info']['AuthorURI'] . '">' . $report['local_info']['Author'] . '</a></td>';
434 352 } else {
@@ -433,53 +351,19 @@
433 351 $html .= '<td><a href="' . $report['local_info']['AuthorURI'] . '">' . $report['local_info']['Author'] . '</a></td>';
434 352 } else {
435 353 $html .= '<td>' . $report['local_info']['Author'] . '</td>';
436 354 }
437 -
438 - // Repository.
439 - if ( isset( $report['local_info']['UpdateURI'] ) ) {
440 - // Parse the UpdateURI's value to get the host.
441 - $parsed_repo_url = wp_parse_url( $report['local_info']['UpdateURI'] );
442 - // If the URI is valid, extract the host, otherwise we'll use the header value.
443 - $repo_host = isset( $parsed_repo_url['host'] ) ? $parsed_repo_url['host'] : $report['local_info']['UpdateURI'];
444 - // Check if the plugin is supposed to be hosted on wp.org.
445 - if ( empty( $repo_host ) || strtolower( $repo_host ) === 'w.org' || strtolower( $repo_host ) === 'wordpress.org' ) {
446 - // Plugin should be available on wp.org, check if we got a 'not found' error.
447 - if ( isset( $report['repo_error_code'] ) && $report['repo_error_code'] === 'plugins_api_failed' ) {
448 - // Plugin is not available in the wp.org repo.
449 - if( isset( $report['exists_in_svn'] ) && $report['exists_in_svn'] === true ) {
450 - $html .= '<td class="' . self::CSS_CLASS_HIGH . '">' . __( 'wordpress.org, plugin closed', 'plugin-report' ) . '</td>';
451 - } else {
452 - $html .= '<td class="' . self::CSS_CLASS_HIGH . '">' . __( 'wordpress.org, plugin not found', 'plugin-report' ) . '</td>';
453 - }
454 - } else {
455 - // Plugin is available on wp.org.
456 - $html .= '<td class="' . self::CSS_CLASS_LOW . '">wordpress.org</td>';
457 - }
458 - } else {
459 - if ( $parsed_repo_url && isset( $parsed_repo_url[ 'host' ] ) ) {
460 - // Update URI is a valid URL, display the host.
461 - $html .= '<td class="' . self::CSS_CLASS_MED . '">' . $repo_host . '</td>';
462 - } else {
463 - // Some other value (like 'false'), so assume updates are disabled.
464 - $html .= '<td class="' . self::CSS_CLASS_MED . '">' . __( 'Updates disabled', 'plugin-report' ) . '</td>';
465 - }
466 - }
467 - } else {
468 - $html .= $this->render_error_cell();
469 - }
470 -
471 355 // Activated.
472 - $active = __( 'Please clear cache to update', 'plugin-report' );
356 + $active = __( 'Please clear cache to update', 'plugin-report' );
473 357 $css_class = self::CSS_CLASS_MED;
474 358 if ( is_multisite() ) {
475 359 $activation_status = $this->get_multisite_activation( $report['file_path'] );
476 360 if ( true === $activation_status['network'] ) {
477 361 $css_class = self::CSS_CLASS_LOW;
478 - $html .= '<td class="' . $css_class . '">' . __( 'Network activated', 'plugin-report' ) . '</td>';
362 + $html .= '<td class="' . $css_class . '">' . __( 'Network activated', 'plugin-report' ) . '</td>';
479 363 } else {
480 364 $css_class = ( $activation_status['active'] > 0 ) ? self::CSS_CLASS_LOW : self::CSS_CLASS_HIGH;
481 - $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>';
482 366 }
483 367 } else {
484 368 if ( isset( $report['file_path'] ) ) {
485 369 $active = is_plugin_active( $report['file_path'] ) ? __( 'Yes', 'plugin-report' ) : __( 'No', 'plugin-report' );
@@ -486,31 +370,31 @@
486 370 $css_class = is_plugin_active( $report['file_path'] ) ? self::CSS_CLASS_LOW : self::CSS_CLASS_HIGH;
487 371 }
488 372 $html .= '<td class="' . $css_class . '">' . $active . '</td>';
489 373 }
490 -
491 374 // Installed / available version.
492 375 if ( isset( $report['repo_info'] ) ) {
493 376 $css_class = $this->get_version_risk_classname( $report['local_info']['Version'], $report['repo_info']->version );
494 - $html .= '<td class="' . $css_class . '">';
495 - $html .= $report['local_info']['Version'];
496 - 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 ) {
497 380 // Any platform upgrades needed?
381 + global $wp_version;
498 382 $needs_php_upgrade = isset( $report['repo_info']->requires_php ) ? version_compare( phpversion(), $report['repo_info']->requires_php, '<' ) : false;
499 383 $needs_wp_upgrade = isset( $report['repo_info']->requires ) ? version_compare( $wp_version, $report['repo_info']->requires, '<' ) : false;
500 384 // Create the additional message.
501 385 if ( $needs_wp_upgrade && $needs_php_upgrade ) {
502 386 /* translators: %1$s: Plugin version number, %2$s: WP version number, %3$s: PHP version number */
503 - $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>';
504 388 } elseif ( $needs_wp_upgrade ) {
505 389 /* translators: %1$s: Plugin version number, %2$s: WP version number. */
506 - $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>';
507 391 } elseif ( $needs_php_upgrade ) {
508 392 /* translators: %1$s: Plugin version number, %2$s: PHP version number. */
509 - $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>';
510 394 } else {
511 395 /* translators: %s: Plugin version number. */
512 - $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>';
513 397 }
514 398 }
515 399 $html .= '</td>';
516 400 } else {
@@ -515,22 +399,10 @@
515 399 $html .= '</td>';
516 400 } else {
517 401 $html .= '<td>' . $report['local_info']['Version'] . '</td>';
518 402 }
519 -
520 - // Auto-update.
521 - if ( version_compare( $wp_version, '5.5', '<' ) ) {
522 - $html .= '<td>' . __( 'Requires WordPress 5.5 or higher', 'plugin-report' ) . '</td>';
523 - } else {
524 - if ( isset( $report['auto-update'] ) && $report['auto-update'] ) {
525 - $html .= '<td class="' . self::CSS_CLASS_LOW . '">' . __( 'Enabled', 'plugin-report' ) . '</td>';
526 - } else {
527 - $html .= '<td>' . __( 'Not enabled', 'plugin-report' ) . '</td>';
528 - }
529 - }
530 -
531 403 // Last updates.
532 - if ( isset( $report['repo_info'] ) && isset( $report['repo_info']->last_updated ) ) {
404 + if ( isset( $report['repo_info'] ) ) {
533 405 $time_update = new DateTime( $report['repo_info']->last_updated );
534 406 $time_diff = human_time_diff( $time_update->getTimestamp(), current_time( 'timestamp' ) );
535 407 $css_class = $this->get_timediff_risk_classname( current_time( 'timestamp' ) - $time_update->getTimestamp() );
536 408 $html .= '<td class="' . $css_class . '" data-sort="' . $time_update->getTimestamp() . '">' . $time_diff . '</td>';
@@ -536,19 +408,17 @@
536 408 $html .= '<td class="' . $css_class . '" data-sort="' . $time_update->getTimestamp() . '">' . $time_diff . '</td>';
537 409 } else {
538 410 $html .= $this->render_error_cell();
539 411 }
540 -
541 412 // Tested up to.
542 - if ( isset( $report['repo_info'] ) && isset( $report['repo_info']->tested ) ) {
543 - $css_class = $this->get_version_risk_classname( $report['repo_info']->tested, $wp_latest, true );
544 - $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>';
545 416 } else {
546 417 $html .= $this->render_error_cell();
547 418 }
548 -
549 419 // Overall user rating.
550 - if ( isset( $report['repo_info'] ) && isset( $report['repo_info']->num_ratings ) && isset( $report['repo_info']->rating ) ) {
420 + if ( isset( $report['repo_info'] ) ) {
551 421 $css_class = ( intval( $report['repo_info']->num_ratings ) > 0 ) ? $this->get_percentage_risk_classname( intval( $report['repo_info']->rating ) ) : '';
552 422 $value_text = ( ( intval( $report['repo_info']->num_ratings ) > 0 ) ? $report['repo_info']->rating . '%' : esc_html__( 'No data available', 'plugin-report' ) );
553 423 $html .= '<td class="' . $css_class . '">' . $value_text . '</td>';
554 424 } else {
@@ -553,9 +423,8 @@
553 423 $html .= '<td class="' . $css_class . '">' . $value_text . '</td>';
554 424 } else {
555 425 $html .= $this->render_error_cell();
556 426 }
557 -
558 427 // Close the new table row.
559 428 $html .= '</tr>';
560 429 }
561 430 return $html;
@@ -562,11 +431,9 @@
562 431 }
563 432
564 433
565 434 /**
566 - * Format an error message as a table row, so we can return it to javascript.
567 - *
568 - * @param string $message Message to be shown.
435 + * Format an error message as a table row, so we can return it to javascript
569 436 */
570 437 private function render_error_row( $message ) {
571 438 return '<tr class="pluginreport-row-error"><td colspan="' . self::COLS_PER_ROW . '">' . $message . '</td></tr>';
572 439 }
@@ -572,11 +439,9 @@
572 439 }
573 440
574 441
575 442 /**
576 - * Format an error message as a table cell, so we can return it to javascript.
577 - *
578 - * @param string $message Message to be shown.
443 + * Format an error message as a table cell, so we can return it to javascript
579 444 */
580 445 private function render_error_cell( $message = null ) {
581 446 if ( ! $message ) {
582 447 $message = esc_html__( 'No data available', 'plugin-report' );
@@ -585,33 +450,11 @@
585 450 }
586 451
587 452
588 453 /**
589 - * Return the version string with all elements beyond the second removed ("5.5.1" -> "5.5").
590 - *
591 - * @param string $version_string Complete version number.
454 + * Figure out what CSS class to use based on current and optimal version numbers
592 455 */
593 - private function get_major_version( $version_string ) {
594 - $parts = explode( '.', $version_string );
595 - array_splice( $parts, 2 );
596 - return implode( '.', $parts );
597 - }
598 -
599 -
600 - /**
601 - * Figure out what CSS class to use based on current and optimal version numbers.
602 - *
603 - * @param string $available Available version.
604 - * @param string $optimal Optimal version.
605 - * @param bool $major_only True to compare only major versions, false otherwise.
606 - */
607 - private function get_version_risk_classname( $available, $optimal, $major_only = false ) {
608 - // Use only the first two elements of the version number if $major_only is set to true.
609 - // This is used for WP version numbers, where point releases are not considered a risk.
610 - if ( $major_only ) {
611 - $available = $this->get_major_version( $available );
612 - $optimal = $this->get_major_version( $optimal );
613 - }
456 + private function get_version_risk_classname( $available, $optimal ) {
614 457 // If the version is equal or higher, indicate low risk.
615 458 if ( version_compare( $available, $optimal, '>=' ) ) {
616 459 return self::CSS_CLASS_LOW;
617 460 }
@@ -620,11 +463,9 @@
620 463 }
621 464
622 465
623 466 /**
624 - * Assess the risk associated with low ratings or poor compatibility feedback, return corresponding CSS class.
625 - *
626 - * @param int $perc Rating percentage.
467 + * Assess the risk associated with low ratings or poor compatibility feedback, return corresponding CSS class
627 468 */
628 469 private function get_percentage_risk_classname( $perc ) {
629 470 if ( $perc < 70 ) {
630 471 return self::CSS_CLASS_HIGH;
@@ -636,11 +477,9 @@
636 477 }
637 478
638 479
639 480 /**
640 - * Assess the risk associated with low ratings or poor compatibility feedback, return corresponding CSS class.
641 - *
642 - * @param string $time_diff Time difference.
481 + * Assess the risk associated with low ratings or poor compatibility feedback, return corresponding CSS class
643 482 */
644 483 private function get_timediff_risk_classname( $time_diff ) {
645 484 $days = $time_diff / ( DAY_IN_SECONDS );
646 485 if ( $days > 365 ) {
@@ -660,13 +499,13 @@
660 499 private function check_core_updates() {
661 500 global $wp_version;
662 501 $update = get_preferred_from_update_core();
663 502 // Bail out of no valid response, or false.
664 - if ( ! $update || false === $update ) {
503 + if ( ! $update || $update == false ) {
665 504 return $wp_version;
666 505 }
667 506 // If latest, return current version number.
668 - if ( 'latest' === $update->response ) {
507 + if ( $update->response == 'latest' ) {
669 508 return $wp_version;
670 509 }
671 510 // Return the preferred update's version number.
672 511 return $update->version;
@@ -673,11 +512,9 @@
673 512 }
674 513
675 514
676 515 /**
677 - * Gather statistics about a plugin's activation on a multisite install.
678 - *
679 - * @param string $path Plugin path.
516 + * Gather statistics about a plugin's activation on a multisite install
680 517 */
681 518 private function get_multisite_activation( $path ) {
682 519 // Create an array to contain the return values.
683 520 $activation_status = array(
@@ -690,9 +527,9 @@
690 527 if ( array_key_exists( $path, $network_plugins ) ) {
691 528 $activation_status['network'] = true;
692 529 } else {
693 530 // Get a list of all sites in the multisite install.
694 - $args = array(
531 + $args = array(
695 532 'number' => 9999,
696 533 'fields' => 'ids',
697 534 );
698 535 $sites = get_sites( $args );
@@ -716,10 +553,8 @@
716 553
717 554
718 555 /**
719 556 * Create a cache key that is unique to the provided plugin slug.
720 - *
721 - * @param string $slug Plugin slug.
722 557 */
723 558 private function create_cache_key( $slug ) {
724 559 // Create a hash for the plugin slug.
725 560 $slug_hash = hash( 'sha256', $slug );
@@ -744,11 +579,9 @@
744 579 }
745 580
746 581
747 582 /**
748 - * Remove the cache item for a single plugin.
749 - *
750 - * @param string $slug Plugin slug.
583 + * Remove the cache item for a single plugin
751 584 */
752 585 private function clear_cache_item( $slug ) {
753 586 if ( isset( $slug ) ) {
754 587 $cache_key = $this->create_cache_key( $slug );