Plugin Directory

Changeset 2072001


Ignore:
Timestamp:
04/21/2019 02:02:22 PM (7 years ago)
Author:
kmvan
Message:

add more items
update UI

Location:
inn-ao-detector/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inn-ao-detector/trunk/inn-ao-detector.php

    r2060184 r2072001  
    11<?php
     2
     3namespace InnStudio\Plugin\InnAoDetector;
    24
    35// Plugin Name: INN AO 主机环境检测器 (INN AO Detector)
     
    57// Description: 启用插件后访问 点击插件名称下方的【开始检测】,以检测您的主机对 INN AO 主题的健康度。(Please click the detection button to detect the host environment compatibility for INN AO theme after plugin enabled.)
    68// Author: Km.Van
    7 // Version: 1.1.1
     9// Version: 2.0.0
    810// Author URI: https://inn-studio.com/ao
    911
    10 class InnStudioInnAoDetector
     12class InnAoDetector
    1113{
    12     private $version         = '1.1.1';
    13     private $themeName       = 'INN AO';
    14     private $themeUrl        = 'https://inn-studio.com/ao';
    15     private $url             = 'https://theme-detector.inn-studio.com/';
    16     private $actionId        = '';
    17     private $basicHeathValue = 60;
     14    private $version             = '2.0.0';
     15    private $themeName           = 'INN AO';
     16    private $themeUrl            = 'https://inn-studio.com/ao';
     17    private $url                 = 'https://theme-detector.inn-studio.com/';
     18    private $actionId            = '';
     19    private $basicHeathValue     = 60;
     20    private $basicSqlite3Version = '3.18';
    1821    private $data;
    1922    private $iconCheck   = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAAEzo7pQAAAAA3NCSVQICAjb4U/gAAAANlBMVEX///9Fx2dFx2dFx2dFx2dFx2dFx2dFx2f////0/Pbw+/Pd9eOL3KB/2Zdx1Ito0oRRy3FFx2dQBNkrAAAAEnRSTlMAIjNVZoi77v////////////8YBaguAAAACXBIWXMAAAsSAAALEgHS3X78AAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNi8xOC8xNwKmd+cAAAElSURBVDiNdVOLksMgCMQYUS+9M/z/zxYQE7i0O5NRZFkeGgAg4I8IqDeaO8CiGz5rfKY72GmuKEsbBIUkgixcV9ioyjIPaK2UeTOUzZv2o1GioiRcZKiTK0gWSRhNQZU8C32QqdFoB+doU1W12NJkrpbudL3oTAvZZ1UUVsLtMnEFJHCdKnZYPThOpgAXMLSUbR6cUn7rmnpWfrLdXqs5MZa9ur3sOjXGsqlYmeN1pQ3Nan+hMt+8KsZ2M3hkDFrRCTmMwPRuTn56Qw785rdb+eAfwzHK083PoC9KuW9o9OM0t+DXSgUX1trx1/3oBUCBwU8suO8n7SjezVVuzhJKcMuj+D4mgY4qfZiztWBv0/7ZB3Z3W+kxT0zwH1tBTVax3H8CvAHlLTE62e8V8AAAAABJRU5ErkJggg==" title="成功 | Success" alt="check" width="32" height="32"/>';
     
    3336    public function filterActionLink($actions, $pluginFile)
    3437    {
    35         if (false !== \stripos($pluginFile, \basename(\dirname(__FILE__)))) {
     38        if (false !== \stripos($pluginFile, \basename(__DIR__))) {
    3639            $adminUrl = \get_admin_url();
    3740            $opts     = <<<HTML
     
    5255    {
    5356        $this->waitCb();
    54         $this->data = $this->check(); ?><!doctype html>
    55 <html <?php language_attributes(); ?>>
     57        $this->data = $this->check();
     58        $url        = \get_bloginfo('url');
     59        $name       = \get_bloginfo('name');
     60        $items      = '';
     61        foreach ($this->items() as $k => $item) {
     62            ++$k;
     63            $items .= <<<HTML
     64<tr>
     65    <td>{$k}</td>
     66    <th>{$item['th']}</th>
     67    <td>{$item['host']}</td>
     68    <td>{$item['theme']}</td>
     69    <td>{$this->getResult($item['result'])}</td>
     70</tr>
     71HTML;
     72        }
     73
     74        $time = \current_time('Y/m/d H:i:s');
     75
     76        echo <<<HTML
     77<!doctype html>
     78<html lang="en-US">
    5679<head>
    5780    <meta charset="UTF-8">
     
    5982    <meta name="renderer" content="webkit"/>
    6083    <meta name="viewport" content="width=device-width,initial-scale=1"/>
    61     <title><?php echo $this->themeName; ?> 主题主机环境检测器(v<?php echo $this->version; ?>) | <?php echo $this->themeName; ?> - Theme Host Environment Detector</title>
     84    <title>{$this->themeName} 主题主机环境检测器(v{$this->version}) | {$this->themeName} - Theme Host Environment Detector</title>
    6285    <style>
    6386    body{
     
    88111        width: 100%;
    89112        background-color: #fafafa;
    90         margin: 1.5rem 0;
     113        margin: 1.5rem 0 0;
    91114        border-spacing: 0;
    92115        border: none;
    93         border-radius: 10px;
     116        border-radius: 10px 10px 0 0;
    94117        box-shadow: 0 5px 20px rgba(0,0,0, .1);
    95118        overflow: hidden;
     
    100123        font-weight: normal;
    101124        text-shadow: 0 1px 2px rgba(0,0,0,.3);
     125        word-break: break-all;
    102126    }
    103127    table thead th:first-child{
    104128        border-radius: 10px 0 0 0;
    105     }
    106     table thead th:last-child{
    107         border-radius: 0 10px 0 0;
    108129    }
    109130    table tbody tr:nth-child(2n){
     
    124145    .btn {
    125146        background-color: #44c767;
    126         border-radius: 50px;
    127         border: 1px solid #18ab29;
    128         display: inline-block;
     147        border-radius:0 0 10px 10px;
     148        display: block;
    129149        color: #fff;
    130         padding: .5rem 1rem;
     150        padding: 1rem 0;
    131151        text-decoration: none;
    132152        text-shadow: 0px 1px 1px #2f6627;
     153        box-shadow: 0 5px 20px rgba(0,0,0, .1);
    133154    }
    134155    .btn:hover {
     
    170191<body>
    171192    <h1>
    172         <?php echo $this->themeName; ?> - 主题主机环境检测器(v<?php echo $this->version; ?>)<br>
    173         <?php echo $this->themeName; ?> - Theme Host Environment Detector
     193        {$this->themeName} - 主题主机环境检测器(v{$this->version})<br>
     194        {$this->themeName} - Theme Host Environment Detector
    174195    </h1>
    175196
     
    178199            <tr>
    179200                <th>序号<br>Number</th>
    180                 <th>检测项目<br>Detection item(<?php echo get_bloginfo('url'); ?>)</th>
    181                 <th>当前主机环境(<?php echo get_bloginfo('name'); ?>)<br>My environment</th>
     201                <th>检测项目<br>Detection item({$url})</th>
     202                <th>当前主机环境({$name})<br>My environment</th>
    182203                <th>主题所需环境<br>Theme required</th>
    183204                <th>检测结果<br>Detection</th>
     
    185206        </thead>
    186207        <tbody>
    187             <?php foreach ($this->items() as $k => $item) {
    188             ?>
    189                 <tr>
    190                     <td><?php echo $k + 1; ?></td>
    191                     <th><?php echo $item['th']; ?></th>
    192                     <td><?php echo $item['host']; ?></td>
    193                     <td><?php echo $item['theme']; ?></td>
    194                     <td><?php echo $this->getResult($item['result']); ?></td>
    195                 </tr>
    196             <?php
    197         } ?>
     208            {$items}
    198209        </tbody>
    199210    </table>
    200211
    201     <?php $this->tools(); ?>
     212    {$this->getTools()}
    202213
    203214    <footer>
    204215        <p>
    205             LOCAL: <?php echo \current_time('Y/m/d H:i:s'); ?>
     216            LOCAL: {$time}
    206217             |
    207             <a href="<?php echo $this->themeUrl; ?>" target="_blank" title="访问主题官网 | Vistit theme official website">INN STUDIO</a>
     218            <a href="{$this->themeUrl}" target="_blank" title="访问主题官网 | Vistit theme official website">INN STUDIO</a>
    208219             |
    209220            <a href="javascript:window.open(false, '_self', false);window.close()"  title="关闭此页面 | Close">Close</a>
    210221    </footer>
    211     <?php $this->showError(); ?>
     222    {$this->getErrors()}
    212223</body>
    213224</html>
    214 <?php
     225HTML;
    215226        die;
    216227    }
     
    220231        if (true === $result) {
    221232            return $this->iconCheck;
    222         } elseif (false === $result) {
     233        }
     234        if (false === $result) {
    223235            return $this->iconTimes;
    224236        }
     
    304316    }
    305317
    306     private function showError()
     318    private function getErrors()
    307319    {
    308320        if ($this->error) {
    309             ?>
    310             <fieldset class="debug">
    311                 <legend>出错信息 | Error information</legend>
    312                 <pre><?php \var_dump($this->error); ?></pre>
    313             </fieldset>
    314             <?php
     321            $err = \json_encode($this->error);
     322
     323            return <<<HTML
     324<fieldset class="debug">
     325    <legend>出错信息 | Error information</legend>
     326    <pre>{$err}</pre>
     327</fieldset>
     328HTML;
    315329        }
    316330    }
     
    375389    {
    376390        return \function_exists('\\exif_imagetype') ? $this->iconCheck : $this->iconTimes;
     391    }
     392
     393    private function getPhpSqlite3()
     394    {
     395        if ( ! \class_exists('\\SQLite3')) {
     396            return '0.0.0';
     397        }
     398
     399        $version = \SQLite3::version();
     400
     401        return $version['versionString'];
     402    }
     403
     404    private function isPastPhpSqlite3()
     405    {
     406        $version = \SQLite3::version();
     407
     408        return \version_compare($version['versionString'], $this->basicSqlite3Version, '>=') ? $this->iconCheck : $this->iconTimes;
     409    }
     410
     411    private function getPhpMbString()
     412    {
     413        return \function_exists('\\mb_strcut') ? $this->iconCheck : $this->iconTimes;
    377414    }
    378415
     
    399436            ),
    400437            array(
     438                'th'     => 'WordPress 健康值<br>WordPress heath value',
     439                'host'   => $this->getHeathValueOther2(),
     440                'theme'  => 100,
     441                'result' => $this->getHeathValueIcon($this->getHeathValueOther2()),
     442            ),
     443            array(
    401444                'th'     => 'PHP Imagick 扩展<br>PHP Imagick Extension',
    402445                'host'   => $this->getPhpImagick(),
     
    411454            ),
    412455            array(
    413                 'th'     => 'WordPress 健康值<br>WordPress heath value',
    414                 'host'   => $this->getHeathValueOther2(),
    415                 'theme'  => 100,
    416                 'result' => $this->getHeathValueIcon($this->getHeathValueOther2()),
     456                'th'     => 'PHP SQLite3 扩展<br>PHP SQLite3 Extension',
     457                'host'   => $this->getPhpSqlite3(),
     458                'theme'  => $this->basicSqlite3Version,
     459                'result' => $this->isPastPhpSqlite3(),
     460            ),
     461            array(
     462                'th'     => 'PHP Multibyte String 扩展<br>PHP Multibyte String Extension',
     463                'host'   => $this->getPhpMbString(),
     464                'theme'  => $this->iconCheck,
     465                'result' => $this->getPhpMbString(),
     466            ),
     467            array(
     468                'th'     => 'PHP GD 图像库<br>PHP GD library',
     469                'host'   => \function_exists('\\imagecreatefrompng') ? $this->iconCheck : $this->iconTimes,
     470                'theme'  => $this->iconCheck,
     471                'result' => \function_exists('\\imagecreatefrompng') ? $this->iconCheck : $this->iconTimes,
     472            ),
     473            array(
     474                'th'     => 'wp-content 目录可写<br>wp-content directory writable',
     475                'host'   => \is_writable(\WP_CONTENT_DIR) ? $this->iconCheck : $this->iconTimes,
     476                'theme'  => $this->iconCheck,
     477                'result' => \is_writable(\WP_CONTENT_DIR) ? $this->iconCheck : $this->iconTimes,
    417478            ),
    418479            array(
     
    425486    }
    426487
    427     private function tools()
    428     {
    429         ?>
    430         <div class="tools">
    431             <a href="javascript:location.reload();document.body.style.opacity='0.3';" class="btn">刷新 | Refresh</a>
    432         </div>
    433         <?php
     488    private function getTools()
     489    {
     490        return <<<HTML
     491<div class="inn-tools">
     492    <a href="javascript:document.body.style.opacity='0.3';location.reload();" class="btn">刷新 | Refresh</a>
     493</div>
     494HTML;
    434495    }
    435496}
    436497
    437498if (\function_exists('add_action')) {
    438     function InnStudioInnAoDetectorInit()
    439     {
    440         new InnStudioInnAoDetector();
    441     }
    442 
    443     \add_action('plugins_loaded', 'InnStudioInnAoDetectorInit');
     499    \add_action('plugins_loaded', function () {
     500        new InnAoDetector();
     501    });
    444502}
  • inn-ao-detector/trunk/readme.txt

    r2043988 r2072001  
    33Tags: checker
    44Requires at least: 4.9.9
    5 Tested up to: 5.1.0
     5Tested up to: 5.1.1
    66Requires PHP: 5.3.0
    77License: GPLv2 or later
     
    2121> Upload to the `/wp-content/plugins/` directory and ENABLE it.
    2222
     23== Changelog ==
     24
     25= 2.0.0 =
     26* 新增更多检测项目
     27* 优化界面
Note: See TracChangeset for help on using the changeset viewer.