Plugin Directory

Changeset 1983445


Ignore:
Timestamp:
11/30/2018 07:23:16 PM (7 years ago)
Author:
johnalarcon
Message:

Add platform version check.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • site-info/trunk/alar-site-info.php

    r1983432 r1983445  
    208208        echo '<h2 class="alar-site-info-subheading">'.__('Installed Version', 'alar-site-info').'</h2>';
    209209        echo '<ul class="alar-site-info-indent-two">';
    210         if (!isset($wp_version)) {
    211             $dashicon = 'warning';
    212             $tooltip = __('Platform version not detected.', 'alar-site-info');
    213             $message = $tooltip;
     210
     211        if (function_exists('classicpress_version')) {
     212            // If ClassicPress.
     213            $dashicon = 'yes';
     214            $tooltip = '';
     215            $message = classicpress_version();
    214216            echo $this->get_list_item($dashicon, $tooltip, $message);
    215217        } else {
    216             $response = wp_remote_get('https://api.wordpress.org/core/version-check/1.7/');
    217             $obj = json_decode($response['body']);
    218             $latest_version = $obj->offers[0]->version;
    219             if (version_compare($wp_version, $latest_version, '=')) {
    220                 $dashicon = 'yes';
    221                 $tooltip = '';
    222                 $message = $wp_version;
     218            // If WordPress.
     219
     220            if (!isset($wp_version)) {
     221                $dashicon = 'warning';
     222                $tooltip = __('Platform version not detected.', 'alar-site-info');
     223                $message = $tooltip;
     224                echo $this->get_list_item($dashicon, $tooltip, $message);
    223225            } else {
    224                 $dashicon = 'warning';
    225                 $tooltip = __('For maximum security and stability, please update your site to the latest version.', 'alar-site-info');
    226                 $message = $wp_version.' [<a href="'.admin_url().'update-core.php">'.__('Update Recommended', 'alar-site-info').'</a>]';
     226                $response = wp_remote_get('https://api.wordpress.org/core/version-check/1.7/');
     227                $obj = json_decode($response['body']);
     228                $latest_version = $obj->offers[0]->version;
     229                if (version_compare($wp_version, $latest_version, '=')) {
     230                    $dashicon = 'yes';
     231                    $tooltip = '';
     232                    $message = $wp_version;
     233                } else {
     234                    $dashicon = 'warning';
     235                    $tooltip = __('For maximum security and stability, please update your site to the latest version.', 'alar-site-info');
     236                    $message = $wp_version.' [<a href="'.admin_url().'update-core.php">'.__('Update Recommended', 'alar-site-info').'</a>]';
     237                }
     238                echo $this->get_list_item($dashicon, $tooltip, $message);
    227239            }
    228             echo $this->get_list_item($dashicon, $tooltip, $message);
    229         }
     240
     241        }
     242
    230243        echo '</ul>';
    231244
Note: See TracChangeset for help on using the changeset viewer.