Changeset 1047208
- Timestamp:
- 12/17/2014 04:32:40 PM (11 years ago)
- Location:
- system-requirements-check/trunk
- Files:
-
- 3 edited
-
includes/class-system-requirements-check-shortcodes.php (modified) (17 diffs)
-
readme.txt (modified) (1 diff)
-
system-requirements-check.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
system-requirements-check/trunk/includes/class-system-requirements-check-shortcodes.php
r982245 r1047208 7 7 */ 8 8 class System_Requirements_Check_Shortcode { 9 9 10 10 /** 11 11 * __construct function … … 16 16 */ 17 17 public function __construct() { 18 18 19 19 // includes 20 20 include_once('system-requirements-check-functions.php'); 21 21 include_once('class-system-requirements-check-system.php'); 22 22 23 23 $GLOBALS['system_to_check'] = new System_Requirements_Check_System(); 24 24 25 25 // add shortcode 26 26 add_shortcode('system_requirements_check', array($this,'check_system_requirements')); 27 27 28 28 // add action 29 29 add_action('wp_enqueue_scripts', array($this, 'frontend_scripts')); 30 31 } 32 30 31 } 32 33 33 /** 34 34 * syc handler function … … 39 39 */ 40 40 public function check_system_requirements() { 41 41 42 42 $osCallout = $this->checkOS(); 43 43 $browserCallout = $this->checkBrowser(); … … 46 46 $javaCallout = $this->checkJava(); 47 47 $flashCallout = $this->checkFlash(); 48 48 49 49 return '<div class="system_req_check">' . $osCallout . $browserCallout . $jsCallout . $cookieCallout . $javaCallout . $flashCallout . '</div>'; 50 51 } 52 50 51 } 52 53 53 /** 54 54 * checkOS function … … 59 59 */ 60 60 public function checkOS() { 61 61 62 62 $osToCheck = array( 63 63 '/windows nt 5.1/i' => prep(get_option('windows_xp')), … … 68 68 '/macintosh|mac os x/i' => prep(get_option('mac')) 69 69 ); 70 $agent = $GLOBALS['system_to_check']->getAgent(); 70 $agent = $GLOBALS['system_to_check']->getAgent(); 71 71 $os = ''; 72 $icon = ''; 72 $icon = ''; 73 73 $found = false; 74 74 75 75 foreach($osToCheck as $key => $value) { 76 76 77 77 if (preg_match($key, $agent) && $value == '1') { 78 78 79 79 switch($key) { 80 80 case '/windows nt 5.1/i': … … 103 103 break; 104 104 } 105 105 106 106 $found = true; 107 107 break; 108 109 } 110 111 } 112 108 109 } 110 111 } 112 113 113 if ($found) { 114 114 115 115 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 117 117 } else { 118 118 119 119 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 125 125 /** 126 126 * recommendOS function … … 129 129 * @return string 130 130 * 131 */ 131 */ 132 132 public function recommendOS($i=false, $system='') { 133 133 134 134 $result = array(); 135 135 $os = ''; 136 136 $ico = ($i) ? "big" : ""; 137 137 138 138 if ($i) { 139 139 140 140 if (prep(get_option('windows_xp')) == '1') { 141 141 $result[] = '<span class="icon-windows '.$ico.'"></span> Windows XP'; 142 142 } 143 143 144 144 if (prep(get_option('windows_vista')) == '1') { 145 145 $result[] = '<span class="icon-windows '.$ico.'"></span> Windows Vista'; 146 146 } 147 147 148 148 if (prep(get_option('windows_7')) == '1') { 149 149 $result[] = '<span class="icon-windows '.$ico.'"></span> Windows 7'; 150 150 } 151 151 152 152 if (prep(get_option('windows_8')) == '1') { 153 153 $result[] = '<span class="icon-windows8 '.$ico.'"></span> Windows 8'; 154 154 } 155 155 156 156 if (prep(get_option('windows_81')) == '1') { 157 157 $result[] = '<span class="icon-windows8 '.$ico.'"></span> Windows 8.1'; 158 158 } 159 159 160 160 if (prep(get_option('mac')) == '1') { 161 161 $result[] = '<span class="icon-apple '.$ico.'"></span> Mac OS X'; 162 162 } 163 163 164 164 } else { 165 165 166 166 if (prep(get_option('windows_xp')) == '1') { 167 167 $result[] = '<span class="icon-windows '.$ico.'"></span> Windows XP'; 168 168 } 169 169 170 170 if (prep(get_option('windows_vista')) == '1' && $system != 'Windows Vista') { 171 171 $result[] = '<span class="icon-windows '.$ico.'"></span> Windows Vista'; 172 172 } 173 173 174 174 if (prep(get_option('windows_7')) == '1' && $system != 'Windows 7') { 175 175 $result[] = '<span class="icon-windows '.$ico.'"></span> Windows 7'; 176 176 } 177 177 178 178 if (prep(get_option('windows_8')) == '1' && $system != 'Windows 8') { 179 179 $result[] = '<span class="icon-windows8 '.$ico.'"></span> Windows 8'; 180 180 } 181 181 182 182 if (prep(get_option('windows_81')) == '1' && $system != 'Windows 8.1') { 183 183 $result[] = '<span class="icon-windows8 '.$ico.'"></span> Windows 8.1'; 184 184 } 185 185 186 186 if (prep(get_option('mac')) == '1' && $system != 'Mac OS X') { 187 187 $result[] = '<span class="icon-apple '.$ico.'"></span> Mac OS X'; 188 188 } 189 190 } 191 192 193 189 190 } 191 192 193 194 194 for ($i = 0; $i < count($result); $i++) { 195 195 $os .= '<li>' . $result[$i] . '</li>'; 196 196 } 197 197 198 198 return '<ul class="os">' . $os .'</ul>'; 199 200 } 201 199 200 } 201 202 202 /** 203 203 * checkBrowser function … … 208 208 */ 209 209 public function checkBrowser() { 210 210 211 211 $browserToCheck = array('/msie|trident/i' => prep(get_option('ie')), 212 212 '/firefox/i' => prep(get_option('firefox')), … … 221 221 $browser = ''; 222 222 $version = ''; 223 223 224 224 foreach($browserToCheck as $key => $value) { 225 225 226 226 if (preg_match($key, $clientBrowser[0])) { 227 227 228 228 if ($value <= 0) { 229 229 $found = false; 230 230 break; 231 231 } 232 232 233 233 $browser = $clientBrowser[0]; 234 234 235 235 switch($browser) { 236 236 case 'trident': … … 259 259 break; 260 260 } 261 261 262 262 if ($clientBrowser[0] != 'trident') { 263 263 264 264 if ($clientBrowser[1] >= $value) { 265 265 $version = $clientBrowser[1]; … … 268 268 $version = $value; 269 269 } 270 270 271 271 } else { 272 272 273 273 if ($clientBrowser[1] >= '7') { 274 274 $version = 11; 275 275 $correctVersion = true; 276 276 } 277 277 278 278 } 279 279 280 280 $found = true; 281 281 break; 282 283 } 284 285 } 286 282 283 } 284 285 } 286 287 287 if ($found) { 288 288 289 289 if ($correctVersion) { 290 290 291 291 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 293 293 } else { 294 294 295 295 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 299 299 } else { 300 300 301 301 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 307 307 /** 308 308 * recommendBrowser function … … 313 313 */ 314 314 public function recommendBrowser($i=false, $browser='') { 315 315 316 316 $result = array(); 317 317 $browsers = ''; 318 318 $ico = ($i) ? "big" : ""; 319 319 320 320 if ($i) { 321 321 322 322 if (prep(get_option('ie')) >= '1') { 323 323 $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>'; 324 324 } 325 325 326 326 if (prep(get_option('firefox')) >= '1') { 327 327 $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>'; 328 328 } 329 329 330 330 if (prep(get_option('chrome')) >= '1') { 331 331 $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>'; 332 332 } 333 333 334 334 if (prep(get_option('opera')) >= '1') { 335 335 $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>'; 336 336 } 337 337 338 338 if (prep(get_option('safari')) >= '1') { 339 339 $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>'; 340 340 } 341 341 342 342 } else { 343 343 344 344 if (prep(get_option('ie')) >= '1' && $browser != 'Internet Explorer') { 345 345 $result[] = '<span class="icon-ie '.$ico.'"></span> Internet Explorer '. prep(get_option('ie')) .'+'; 346 346 } 347 347 348 348 if (prep(get_option('firefox')) >= '1' && $browser != 'Firefox') { 349 349 $result[] = '<span class="icon-firefox '.$ico.'"></span> Firefox '. prep(get_option('firefox')) .'+'; 350 350 } 351 351 352 352 if (prep(get_option('chrome')) >= '1' && $browser != 'Chrome') { 353 353 $result[] = '<span class="icon-chrome '.$ico.'"></span> Chrome '. prep(get_option('chrome')) .'+'; 354 354 } 355 355 356 356 if (prep(get_option('opera')) >= '1' && $browser != 'Opera') { 357 357 $result[] = '<span class="icon-opera '.$ico.'"></span> Opera '. prep(get_option('opera')) .'+'; 358 358 } 359 359 360 360 if (prep(get_option('safari')) >= '1' && $browser != 'Safari') { 361 361 $result[] = '<span class="icon-safari '.$ico.'"></span> Safari '. prep(get_option('safari')) .'+'; 362 362 } 363 364 } 365 366 367 363 364 } 365 366 367 368 368 for ($i = 0; $i < count($result); $i++) { 369 369 $browsers .= '<li>' . $result[$i] . '</li>'; 370 370 } 371 371 372 372 return '<ul class="browser">' . $browsers .'</ul>'; 373 374 } 375 373 374 } 375 376 376 /** 377 377 * checkJS function … … 383 383 */ 384 384 public function checkJS() { 385 385 386 386 $js = prep(get_option('js')); 387 387 388 388 if ($js == 0) return ''; 389 389 390 390 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 394 394 /** 395 395 * checkCookies function … … 401 401 */ 402 402 public function checkCookies() { 403 403 404 404 $cookies = prep(get_option('cookie')); 405 405 406 406 if ($cookies == 0) return ''; 407 407 408 408 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 412 412 /** 413 413 * checkJava function … … 419 419 */ 420 420 public function checkJava() { 421 421 422 422 $jre = prep(get_option('jre')); 423 423 424 424 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 430 430 /** 431 431 * checkFlash function … … 437 437 */ 438 438 public function checkFlash() { 439 439 440 440 $flash = prep(get_option('flash')); 441 441 442 442 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 449 449 /** 450 450 * Register and enqueue scripts and css 451 451 */ 452 452 public function frontend_scripts() { 453 453 454 454 wp_deregister_script('jquery'); 455 455 wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", false, null); 456 456 wp_enqueue_script('jquery'); 457 457 wp_enqueue_style('system-requirements-check-frontend', '' . SYSTEM_REQ_URL . '/assets/css/system-requirements-check-frontend.css'); 458 458 459 459 } 460 460 -
system-requirements-check/trunk/readme.txt
r982245 r1047208 4 4 Tags: cookie, JRE, os, operating, system, flash, requirements, check, checker, browser, javascript, client 5 5 Requires at least: 3.0 6 Tested up to: 4. 07 Stable tag: 0.2.06 Tested up to: 4.1 7 Stable tag: 1.0.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
system-requirements-check/trunk/system-requirements-check.php
r982245 r1047208 4 4 * Plugin URI: http://www.ethanslin.com/plugin/wordpress/system_requirements_check/ 5 5 * 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.06 * Version: 1.0.0 7 7 * Author: Ethan Lin 8 8 * Author URI: http://www.ethanslin.com … … 12 12 13 13 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 15 15 published by the Free Software Foundation. 16 16 … … 34 34 */ 35 35 class System_Requirements_Check { 36 36 37 37 /** 38 38 * Constructor - set and hook up the plugin 39 39 */ 40 40 public function __construct() { 41 41 42 42 // add a setting page 43 43 include( sprintf( "%s/includes/admin/class-system-requirements-check-settings.php", dirname( __FILE__ ) ) ); 44 44 $this->settings_page = new System_Requirements_Check_Settings(); 45 45 46 46 // actions 47 47 add_action( 'admin_menu', array( $this, 'add_menu' ) ); … … 49 49 50 50 } 51 51 52 52 /** 53 53 * Activate the plugin … … 67 67 68 68 } 69 69 70 70 /** 71 71 * add a menu 72 72 */ 73 73 public function add_menu() { 74 74 75 75 add_options_page( 'System Requirements Check', 'System Requirements Check', 'manage_options', 'system_requirements_check', array( $this->settings_page, 'output' ) ); 76 76 77 77 } 78 78 79 79 /** 80 80 * Add Admin CSS files 81 81 */ 82 82 public function backend_scripts() { 83 83 84 84 wp_enqueue_style( 'system-requirements-check-settings', plugin_dir_url(__FILE__) . 'assets/css/system-requirements-check-settings.css' ); 85 85 86 86 } 87 87 88 88 } // end class System_Requirements_Check 89 89 … … 94 94 if ( is_admin() ) 95 95 $system_requirements_check = new System_Requirements_Check(); 96 96 97 97 // add shortcode 98 98 require_once( "includes/class-system-requirements-check-shortcodes.php" );
Note: See TracChangeset
for help on using the changeset viewer.