Plugin Directory

Changeset 1047208


Ignore:
Timestamp:
12/17/2014 04:32:40 PM (11 years ago)
Author:
eslin87
Message:

Updated to be compatible with with WordPress 4.1

Location:
system-requirements-check/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • system-requirements-check/trunk/includes/class-system-requirements-check-shortcodes.php

    r982245 r1047208  
    77 */
    88class System_Requirements_Check_Shortcode {
    9    
     9
    1010    /**
    1111     * __construct function
     
    1616     */
    1717    public function __construct() {
    18    
     18
    1919        // includes
    2020        include_once('system-requirements-check-functions.php');
    2121        include_once('class-system-requirements-check-system.php');
    22        
     22
    2323        $GLOBALS['system_to_check'] = new System_Requirements_Check_System();
    24        
     24
    2525        // add shortcode
    2626        add_shortcode('system_requirements_check', array($this,'check_system_requirements'));
    27        
     27
    2828        // add action
    2929        add_action('wp_enqueue_scripts', array($this, 'frontend_scripts'));
    30    
    31     }
    32      
     30
     31    }
     32
    3333    /**
    3434     * syc handler function
     
    3939     */
    4040    public function check_system_requirements() {
    41    
     41
    4242        $osCallout = $this->checkOS();
    4343        $browserCallout = $this->checkBrowser();
     
    4646        $javaCallout = $this->checkJava();
    4747        $flashCallout = $this->checkFlash();
    48        
     48
    4949        return '<div class="system_req_check">' . $osCallout . $browserCallout . $jsCallout . $cookieCallout . $javaCallout . $flashCallout . '</div>';
    50    
    51     }
    52      
     50
     51    }
     52
    5353    /**
    5454     * checkOS function
     
    5959     */
    6060    public function checkOS() {
    61    
     61
    6262        $osToCheck = array(
    6363                           '/windows nt 5.1/i'     => prep(get_option('windows_xp')),
     
    6868                           '/macintosh|mac os x/i' => prep(get_option('mac'))
    6969                          );
    70         $agent = $GLOBALS['system_to_check']->getAgent();   
     70        $agent = $GLOBALS['system_to_check']->getAgent();
    7171        $os = '';
    72         $icon = '';     
     72        $icon = '';
    7373        $found = false;
    74        
     74
    7575        foreach($osToCheck as $key => $value) {
    76        
     76
    7777            if (preg_match($key, $agent) && $value == '1') {
    78            
     78
    7979            switch($key) {
    8080                case '/windows nt 5.1/i':
     
    103103                break;
    104104            }
    105            
     105
    106106            $found = true;
    107107            break;
    108            
    109             }
    110        
    111         }
    112        
     108
     109            }
     110
     111        }
     112
    113113        if ($found) {
    114        
     114
    115115            return '<div class="callout success"><p><span class="icon-checkmark big green"></span><strong>' . $icon . $os . '</strong></p>' . $this->recommendOS(false,$os) . '</div>';
    116        
     116
    117117        } else {
    118        
     118
    119119            return '<div class="callout danger"><p><span class="icon-danger big red"></span><strong>Your operating system does not meet the requirement!</strong></p><p>Recommended operating systems:' . $this->recommendOS(true) . '</p></div>';
    120        
    121         }
    122    
    123     }
    124    
     120
     121        }
     122
     123    }
     124
    125125    /**
    126126     * recommendOS function
     
    129129     * @return string
    130130     *
    131      */ 
     131     */
    132132    public function recommendOS($i=false, $system='') {
    133    
     133
    134134        $result = array();
    135135        $os = '';
    136136        $ico = ($i) ? "big" : "";
    137        
     137
    138138        if ($i) {
    139            
     139
    140140            if (prep(get_option('windows_xp')) == '1') {
    141141                $result[] = '<span class="icon-windows '.$ico.'"></span> Windows XP';
    142142            }
    143            
     143
    144144            if (prep(get_option('windows_vista')) == '1') {
    145145                $result[] = '<span class="icon-windows '.$ico.'"></span> Windows Vista';
    146146            }
    147            
     147
    148148            if (prep(get_option('windows_7')) == '1') {
    149149                $result[] = '<span class="icon-windows '.$ico.'"></span> Windows 7';
    150150            }
    151            
     151
    152152            if (prep(get_option('windows_8')) == '1') {
    153153                $result[] = '<span class="icon-windows8 '.$ico.'"></span> Windows 8';
    154154            }
    155            
     155
    156156            if (prep(get_option('windows_81')) == '1') {
    157157                $result[] = '<span class="icon-windows8 '.$ico.'"></span> Windows 8.1';
    158158            }
    159            
     159
    160160            if (prep(get_option('mac')) == '1') {
    161161                $result[] = '<span class="icon-apple '.$ico.'"></span> Mac OS X';
    162162            }
    163            
     163
    164164        } else {
    165            
     165
    166166            if (prep(get_option('windows_xp')) == '1') {
    167167                $result[] = '<span class="icon-windows '.$ico.'"></span> Windows XP';
    168168            }
    169            
     169
    170170            if (prep(get_option('windows_vista')) == '1' && $system != 'Windows Vista') {
    171171                $result[] = '<span class="icon-windows '.$ico.'"></span> Windows Vista';
    172172            }
    173            
     173
    174174            if (prep(get_option('windows_7')) == '1' && $system != 'Windows 7') {
    175175                $result[] = '<span class="icon-windows '.$ico.'"></span> Windows 7';
    176176            }
    177            
     177
    178178            if (prep(get_option('windows_8')) == '1' && $system != 'Windows 8') {
    179179                $result[] = '<span class="icon-windows8 '.$ico.'"></span> Windows 8';
    180180            }
    181            
     181
    182182            if (prep(get_option('windows_81')) == '1' && $system != 'Windows 8.1') {
    183183                $result[] = '<span class="icon-windows8 '.$ico.'"></span> Windows 8.1';
    184184            }
    185            
     185
    186186            if (prep(get_option('mac')) == '1' && $system != 'Mac OS X') {
    187187                $result[] = '<span class="icon-apple '.$ico.'"></span> Mac OS X';
    188188            }
    189            
    190         }
    191        
    192        
    193        
     189
     190        }
     191
     192
     193
    194194        for ($i = 0; $i < count($result); $i++) {
    195195            $os .= '<li>' . $result[$i] . '</li>';
    196196        }
    197        
     197
    198198        return '<ul class="os">' . $os .'</ul>';
    199    
    200     }
    201      
     199
     200    }
     201
    202202    /**
    203203     * checkBrowser function
     
    208208     */
    209209    public function checkBrowser() {
    210    
     210
    211211        $browserToCheck = array('/msie|trident/i'   => prep(get_option('ie')),
    212212                                '/firefox/i'        => prep(get_option('firefox')),
     
    221221        $browser = '';
    222222        $version = '';
    223        
     223
    224224        foreach($browserToCheck as $key => $value) {
    225        
     225
    226226            if (preg_match($key, $clientBrowser[0])) {
    227            
     227
    228228                if ($value <= 0) {
    229229                    $found = false;
    230230                    break;
    231231                }
    232                
     232
    233233                $browser = $clientBrowser[0];
    234                
     234
    235235                switch($browser) {
    236236                    case 'trident':
     
    259259                    break;
    260260                }
    261                
     261
    262262                if ($clientBrowser[0] != 'trident') {
    263                
     263
    264264                    if ($clientBrowser[1] >= $value) {
    265265                        $version = $clientBrowser[1];
     
    268268                        $version = $value;
    269269                    }
    270                    
     270
    271271                } else {
    272                
     272
    273273                    if ($clientBrowser[1] >= '7') {
    274274                        $version = 11;
    275275                        $correctVersion = true;
    276276                    }
    277                    
     277
    278278                }
    279                
     279
    280280                $found = true;
    281281                break;
    282                
    283             }
    284        
    285         }
    286        
     282
     283            }
     284
     285        }
     286
    287287        if ($found) {
    288        
     288
    289289            if ($correctVersion) {
    290            
     290
    291291                return '<div class="callout success"><p><span class="icon-checkmark big green"></span><strong>' . $icon . $browser . ' ('.$version.')' . '</strong></p>' . $this->recommendBrowser(false,$browser) . '</div>';
    292                
     292
    293293            } else {
    294            
     294
    295295                return '<div class="callout warning"><p><span class="icon-warning big yellow"></span><strong>' . $icon . $browser . ' (' . $clientBrowser[1] . ') - <span class="warning">UPDATE REQUIRED</span></strong></p><p>Your web browser browser is outdated. Please update <strong>' . $browser . '</strong> to version <strong>' .$version.' or greater</strong>.</p></div>';
    296                
    297             }
    298        
     296
     297            }
     298
    299299        } else {
    300        
     300
    301301            return '<div class="callout danger"><p><span class="icon-danger big red"></span><strong>Your web browser is not supported!</strong></p><p>Please try using any of the following web browsers:'. $this->recommendBrowser() .'</p></div>';
    302        
    303         }
    304    
    305     }
    306      
     302
     303        }
     304
     305    }
     306
    307307    /**
    308308     * recommendBrowser function
     
    313313     */
    314314    public function recommendBrowser($i=false, $browser='') {
    315    
     315
    316316        $result = array();
    317317        $browsers = '';
    318318        $ico = ($i) ? "big" : "";
    319        
     319
    320320        if ($i) {
    321            
     321
    322322            if (prep(get_option('ie')) >= '1') {
    323323                $result[] = '<span class="icon-ie '.$ico.'"></span> <a href="http://windows.microsoft.com/en-us/internet-explorer/download-ie" target="_blank">Internet Explorer</a><span class="icon-link"></span> <small>(version '. prep(get_option('ie')) .'+)</small>';
    324324            }
    325            
     325
    326326            if (prep(get_option('firefox')) >= '1') {
    327327                $result[] = '<span class="icon-firefox '.$ico.'"></span> <a href="https://www.mozilla.org/en-US/firefox/new/" target="_blank">Firefox</a><span class="icon-link"></span> <small>(version '. prep(get_option('firefox')) .'+)</small>';
    328328            }
    329            
     329
    330330            if (prep(get_option('chrome')) >= '1') {
    331331                $result[] = '<span class="icon-chrome '.$ico.'"></span> <a href="https://www.google.com/intl/en/chrome/browser/" target="_blank">Chrome</a><span class="icon-link"></span> <small>(version '. prep(get_option('chrome')) .'+)</small>';
    332332            }
    333            
     333
    334334            if (prep(get_option('opera')) >= '1') {
    335335                $result[] = '<span class="icon-opera '.$ico.'"></span> <a href="http://www.opera.com/" target="_blank">Opera</a><span class="icon-link"></span> <small>(version '. prep(get_option('opera')) .'+)</small>';
    336336            }
    337            
     337
    338338            if (prep(get_option('safari')) >= '1') {
    339339                $result[] = '<span class="icon-safari '.$ico.'"></span> <a href="https://www.apple.com/safari/" target="_blank">Safari</a><span class="icon-link"></span> <small>(version '. prep(get_option('safari')) .'+)</small>';
    340340            }
    341            
     341
    342342        } else {
    343            
     343
    344344            if (prep(get_option('ie')) >= '1' && $browser != 'Internet Explorer') {
    345345                $result[] = '<span class="icon-ie '.$ico.'"></span> Internet Explorer '. prep(get_option('ie')) .'+';
    346346            }
    347            
     347
    348348            if (prep(get_option('firefox')) >= '1' && $browser != 'Firefox') {
    349349                $result[] = '<span class="icon-firefox '.$ico.'"></span> Firefox '. prep(get_option('firefox')) .'+';
    350350            }
    351            
     351
    352352            if (prep(get_option('chrome')) >= '1' && $browser != 'Chrome') {
    353353                $result[] = '<span class="icon-chrome '.$ico.'"></span> Chrome '. prep(get_option('chrome')) .'+';
    354354            }
    355            
     355
    356356            if (prep(get_option('opera')) >= '1' && $browser != 'Opera') {
    357357                $result[] = '<span class="icon-opera '.$ico.'"></span> Opera '. prep(get_option('opera')) .'+';
    358358            }
    359            
     359
    360360            if (prep(get_option('safari')) >= '1' && $browser != 'Safari') {
    361361                $result[] = '<span class="icon-safari '.$ico.'"></span> Safari '. prep(get_option('safari')) .'+';
    362362            }
    363            
    364         }
    365        
    366        
    367        
     363
     364        }
     365
     366
     367
    368368        for ($i = 0; $i < count($result); $i++) {
    369369            $browsers .= '<li>' . $result[$i] . '</li>';
    370370        }
    371        
     371
    372372        return '<ul class="browser">' . $browsers .'</ul>';
    373    
    374     }
    375      
     373
     374    }
     375
    376376    /**
    377377     * checkJS function
     
    383383     */
    384384    public function checkJS() {
    385    
     385
    386386        $js = prep(get_option('js'));
    387    
     387
    388388        if ($js == 0) return '';
    389    
     389
    390390        return '<script type="text/javascript" src="'.SYSTEM_REQ_URL.'/assets/js/checkJS.js"></script><noscript><div class="callout danger"><p><span class="icon-danger big red"></span><span class="icon-javascript big"></span><strong>JavaScript is disabled!</strong> - Please <a href="http://enable-javascript.com/" target="_blank">enable</a><span class="icon-link"></span> JavaScript!</p></div></noscript>';
    391    
    392     }
    393    
     391
     392    }
     393
    394394    /**
    395395     * checkCookies function
     
    401401     */
    402402    public function checkCookies() {
    403    
     403
    404404        $cookies = prep(get_option('cookie'));
    405    
     405
    406406        if ($cookies == 0) return '';
    407    
     407
    408408        return '<script type="text/javascript" src="'.SYSTEM_REQ_URL.'/assets/js/checkCookies.js"></script><noscript><div class="callout warning"><p><span class="icon-cancel big yellow"></span><strong>Cookies check failed!</strong> - JavaScript is required. Please <a href="http://enable-javascript.com/" target="_blank">enable</a><span class="icon-link"></span> JavaScript!</p></div></noscript>';
    409    
    410     }
    411      
     409
     410    }
     411
    412412    /**
    413413     * checkJava function
     
    419419     */
    420420    public function checkJava() {
    421    
     421
    422422        $jre = prep(get_option('jre'));
    423        
     423
    424424        if ($jre <= 0) return '';
    425        
    426         return '<input id="checkJV" type="hidden" value="'.$jre.'" /><script type="text/javascript" src="http://java.com/js/deployJava.js"></script><script type="text/javascript" src="'.SYSTEM_REQ_URL.'/assets/js/checkJava.js"></script><noscript><div class="callout warning"><p><span class="icon-cancel big yellow"></span><span class="icon-java big"></span><strong>Java check failed!</strong> - JavaScript is required. Please <a href="http://enable-javascript.com/" target="_blank">enable</a><span class="icon-link"></span> JavaScript!</p></div></noscript>';
    427    
    428     }
    429      
     425
     426        return '<input id="checkJV" type="hidden" value="'.$jre.'" /><script type="text/javascript" src="http' . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . '://java.com/js/deployJava.js"></script><script type="text/javascript" src="'.SYSTEM_REQ_URL.'/assets/js/checkJava.js"></script><noscript><div class="callout warning"><p><span class="icon-cancel big yellow"></span><span class="icon-java big"></span><strong>Java check failed!</strong> - JavaScript is required. Please <a href="http://enable-javascript.com/" target="_blank">enable</a><span class="icon-link"></span> JavaScript!</p></div></noscript>';
     427
     428    }
     429
    430430    /**
    431431     * checkFlash function
     
    437437     */
    438438    public function checkFlash() {
    439    
     439
    440440        $flash = prep(get_option('flash'));
    441    
     441
    442442        if ($flash <= 0) return '';
    443    
    444         return '<input id="checkFL" type="hidden" value="'.$flash.'" /><script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script><script type="text/javascript" src="'.SYSTEM_REQ_URL.'/assets/js/checkFlash.js"></script><noscript><div class="callout warning"><p><span class="icon-cancel big yellow"></span><strong>Adobe Flash Player check failed!</strong> - JavaScript is required. Please <a href="http://enable-javascript.com/" target="_blank">enable</a><span class="icon-link"></span> JavaScript!</p></div></noscript>';
    445    
    446     }
    447      
    448      
     443
     444        return '<input id="checkFL" type="hidden" value="'.$flash.'" /><script src="http' . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . '://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script><script type="text/javascript" src="'.SYSTEM_REQ_URL.'/assets/js/checkFlash.js"></script><noscript><div class="callout warning"><p><span class="icon-cancel big yellow"></span><strong>Adobe Flash Player check failed!</strong> - JavaScript is required. Please <a href="http://enable-javascript.com/" target="_blank">enable</a><span class="icon-link"></span> JavaScript!</p></div></noscript>';
     445
     446    }
     447
     448
    449449    /**
    450450     * Register and enqueue scripts and css
    451451     */
    452452    public function frontend_scripts() {
    453        
     453
    454454        wp_deregister_script('jquery');
    455455        wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", false, null);
    456456        wp_enqueue_script('jquery');
    457457        wp_enqueue_style('system-requirements-check-frontend', '' . SYSTEM_REQ_URL . '/assets/css/system-requirements-check-frontend.css');
    458    
     458
    459459    }
    460460
  • system-requirements-check/trunk/readme.txt

    r982245 r1047208  
    44Tags: cookie, JRE, os, operating, system, flash, requirements, check, checker, browser, javascript, client
    55Requires at least: 3.0
    6 Tested up to: 4.0
    7 Stable tag: 0.2.0
     6Tested up to: 4.1
     7Stable tag: 1.0.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • system-requirements-check/trunk/system-requirements-check.php

    r982245 r1047208  
    44 * Plugin URI: http://www.ethanslin.com/plugin/wordpress/system_requirements_check/
    55 * Description: A minimum system requirements plugin that checks for specified version of the operating systems, web browsers, Adobe Flash Player, Java Runtime Environment (JRE), Cookie, and Javascript on the client side. The result will be displayed on a post or page with the use of a short code  to let the end-users be aware of that their system may not be optimal for specific tasks or operations.
    6  * Version: 0.2.0
     6 * Version: 1.0.0
    77 * Author: Ethan Lin
    88 * Author URI: http://www.ethanslin.com
     
    1212
    1313    This program is free software; you can redistribute it and/or modify
    14     it under the terms of the GNU General Public License, version 2, as 
     14    it under the terms of the GNU General Public License, version 2, as
    1515    published by the Free Software Foundation.
    1616
     
    3434 */
    3535class System_Requirements_Check {
    36    
     36
    3737    /**
    3838     * Constructor - set and hook up the plugin
    3939     */
    4040    public function __construct() {
    41        
     41
    4242        // add a setting page
    4343        include( sprintf( "%s/includes/admin/class-system-requirements-check-settings.php", dirname( __FILE__ ) ) );
    4444        $this->settings_page = new System_Requirements_Check_Settings();
    45        
     45
    4646        // actions
    4747        add_action( 'admin_menu', array( $this, 'add_menu' ) );
     
    4949
    5050    }
    51    
     51
    5252    /**
    5353     * Activate the plugin
     
    6767
    6868    }
    69    
     69
    7070    /**
    7171     * add a menu
    7272     */
    7373    public function add_menu() {
    74        
     74
    7575        add_options_page( 'System Requirements Check', 'System Requirements Check', 'manage_options', 'system_requirements_check', array( $this->settings_page, 'output' ) );
    76        
     76
    7777    }
    78    
     78
    7979    /**
    8080     * Add Admin CSS files
    8181     */
    8282    public function backend_scripts() {
    83        
     83
    8484        wp_enqueue_style( 'system-requirements-check-settings', plugin_dir_url(__FILE__) . 'assets/css/system-requirements-check-settings.css' );
    85        
     85
    8686    }
    87    
     87
    8888} // end class System_Requirements_Check
    8989
     
    9494if ( is_admin() )
    9595    $system_requirements_check = new System_Requirements_Check();
    96    
     96
    9797// add shortcode
    9898require_once( "includes/class-system-requirements-check-shortcodes.php" );
Note: See TracChangeset for help on using the changeset viewer.