0 ) { $results[] = new Result( 'updates.plugins', $plugin_count >= 5 ? Result::CRITICAL : Result::RECOMMENDED, /* translators: %d: number of plugins */ sprintf( _n( '%d plugin has an update', '%d plugins have updates', $plugin_count, 'keepwatch' ), $plugin_count ), __( 'Outdated plugins are the most common way sites get compromised.', 'keepwatch' ), admin_url( 'plugins.php?plugin_status=upgrade' ), __( 'Review plugins', 'keepwatch' ) ); } $theme_count = self::count_responses( $themes ); if ( $theme_count > 0 ) { $results[] = new Result( 'updates.themes', Result::RECOMMENDED, /* translators: %d: number of themes */ sprintf( _n( '%d theme has an update', '%d themes have updates', $theme_count, 'keepwatch' ), $theme_count ), __( 'Keep installed themes up to date, or delete the ones you do not use.', 'keepwatch' ), admin_url( 'themes.php' ), __( 'Review themes', 'keepwatch' ) ); } if ( array() === $results ) { $results[] = new Result( 'updates.all', Result::GOOD, __( 'WordPress, plugins and themes are up to date', 'keepwatch' ) ); } return $results; } /** * Version offered as an upgrade, if any. * * @param mixed $core update_core transient. */ private static function core_upgrade( $core ): ?string { if ( ! is_object( $core ) || ! isset( $core->updates ) || ! is_array( $core->updates ) ) { return null; } foreach ( $core->updates as $update ) { if ( is_object( $update ) && isset( $update->response ) && 'upgrade' === $update->response ) { return isset( $update->current ) ? (string) $update->current : ''; } } return null; } /** * Number of entries in a plugin/theme update transient's "response" list. * * @param mixed $transient Transient value. */ private static function count_responses( $transient ): int { if ( is_object( $transient ) && isset( $transient->response ) && is_array( $transient->response ) ) { return count( $transient->response ); } return 0; } }