@@ -14,24 +14,24 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | 16 | // Exit if accessed directly. |
| 17 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 17 | +if ( ! defined('ABSPATH')) { |
|
| 18 | 18 | exit; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | // Plugin constants. |
| 22 | -$this_plugin_path = trailingslashit( dirname( __FILE__ ) ); |
|
| 23 | -$this_plugin_dir = plugin_dir_url( __FILE__ ); |
|
| 22 | +$this_plugin_path = trailingslashit(dirname(__FILE__)); |
|
| 23 | +$this_plugin_dir = plugin_dir_url(__FILE__); |
|
| 24 | 24 | $this_plugin_constants = array( |
| 25 | 25 | 'SIMPLE_CALENDAR_VERSION' => '3.0.15', |
| 26 | 26 | 'SIMPLE_CALENDAR_MAIN_FILE' => __FILE__, |
| 27 | 27 | 'SIMPLE_CALENDAR_URL' => $this_plugin_dir, |
| 28 | - 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir . 'assets/', |
|
| 28 | + 'SIMPLE_CALENDAR_ASSETS' => $this_plugin_dir.'assets/', |
|
| 29 | 29 | 'SIMPLE_CALENDAR_PATH' => $this_plugin_path, |
| 30 | - 'SIMPLE_CALENDAR_INC' => $this_plugin_path . 'includes/', |
|
| 30 | + 'SIMPLE_CALENDAR_INC' => $this_plugin_path.'includes/', |
|
| 31 | 31 | ); |
| 32 | -foreach ( $this_plugin_constants as $constant => $value ) { |
|
| 33 | - if ( ! defined( $constant ) ) { |
|
| 34 | - define( $constant, $value ); |
|
| 32 | +foreach ($this_plugin_constants as $constant => $value) { |
|
| 33 | + if ( ! defined($constant)) { |
|
| 34 | + define($constant, $value); |
|
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | include_once 'includes/wp-requirements.php'; |
| 41 | 41 | |
| 42 | 42 | // Check plugin requirements before loading plugin. |
| 43 | -$this_plugin_checks = new SimCal_WP_Requirements( 'Simple Calendar', plugin_basename( __FILE__ ), array( |
|
| 43 | +$this_plugin_checks = new SimCal_WP_Requirements('Simple Calendar', plugin_basename(__FILE__), array( |
|
| 44 | 44 | 'PHP' => '5.3.3', |
| 45 | 45 | 'WordPress' => '4.1', |
| 46 | 46 | 'Extensions' => array( |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | 'json', |
| 50 | 50 | 'mbstring', |
| 51 | 51 | ), |
| 52 | - ) ); |
|
| 53 | -if ( $this_plugin_checks->pass() === false ) { |
|
| 52 | + )); |
|
| 53 | +if ($this_plugin_checks->pass() === false) { |
|
| 54 | 54 | $this_plugin_checks->halt(); |
| 55 | 55 | |
| 56 | 56 | return; |
@@ -42,1214 +42,1214 @@ |
||
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - class Browser |
|
| 46 | - { |
|
| 47 | - private $_agent = ''; |
|
| 48 | - private $_browser_name = ''; |
|
| 49 | - private $_version = ''; |
|
| 50 | - private $_platform = ''; |
|
| 51 | - private $_os = ''; |
|
| 52 | - private $_is_aol = false; |
|
| 53 | - private $_is_mobile = false; |
|
| 54 | - private $_is_tablet = false; |
|
| 55 | - private $_is_robot = false; |
|
| 56 | - private $_is_facebook = false; |
|
| 57 | - private $_aol_version = ''; |
|
| 58 | - |
|
| 59 | - const BROWSER_UNKNOWN = 'unknown'; |
|
| 60 | - const VERSION_UNKNOWN = 'unknown'; |
|
| 61 | - |
|
| 62 | - const BROWSER_OPERA = 'Opera'; // http://www.opera.com/ |
|
| 63 | - const BROWSER_OPERA_MINI = 'Opera Mini'; // http://www.opera.com/mini/ |
|
| 64 | - const BROWSER_WEBTV = 'WebTV'; // http://www.webtv.net/pc/ |
|
| 65 | - const BROWSER_IE = 'Internet Explorer'; // http://www.microsoft.com/ie/ |
|
| 66 | - const BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // http://en.wikipedia.org/wiki/Internet_Explorer_Mobile |
|
| 67 | - const BROWSER_KONQUEROR = 'Konqueror'; // http://www.konqueror.org/ |
|
| 68 | - const BROWSER_ICAB = 'iCab'; // http://www.icab.de/ |
|
| 69 | - const BROWSER_OMNIWEB = 'OmniWeb'; // http://www.omnigroup.com/applications/omniweb/ |
|
| 70 | - const BROWSER_FIREBIRD = 'Firebird'; // http://www.ibphoenix.com/ |
|
| 71 | - const BROWSER_FIREFOX = 'Firefox'; // http://www.mozilla.com/en-US/firefox/firefox.html |
|
| 72 | - const BROWSER_ICEWEASEL = 'Iceweasel'; // http://www.geticeweasel.org/ |
|
| 73 | - const BROWSER_SHIRETOKO = 'Shiretoko'; // http://wiki.mozilla.org/Projects/shiretoko |
|
| 74 | - const BROWSER_MOZILLA = 'Mozilla'; // http://www.mozilla.com/en-US/ |
|
| 75 | - const BROWSER_AMAYA = 'Amaya'; // http://www.w3.org/Amaya/ |
|
| 76 | - const BROWSER_LYNX = 'Lynx'; // http://en.wikipedia.org/wiki/Lynx |
|
| 77 | - const BROWSER_SAFARI = 'Safari'; // http://apple.com |
|
| 78 | - const BROWSER_IPHONE = 'iPhone'; // http://apple.com |
|
| 79 | - const BROWSER_IPOD = 'iPod'; // http://apple.com |
|
| 80 | - const BROWSER_IPAD = 'iPad'; // http://apple.com |
|
| 81 | - const BROWSER_CHROME = 'Chrome'; // http://www.google.com/chrome |
|
| 82 | - const BROWSER_ANDROID = 'Android'; // http://www.android.com/ |
|
| 83 | - const BROWSER_GOOGLEBOT = 'GoogleBot'; // http://en.wikipedia.org/wiki/Googlebot |
|
| 84 | - const BROWSER_SLURP = 'Yahoo! Slurp'; // http://en.wikipedia.org/wiki/Yahoo!_Slurp |
|
| 85 | - const BROWSER_W3CVALIDATOR = 'W3C Validator'; // http://validator.w3.org/ |
|
| 86 | - const BROWSER_BLACKBERRY = 'BlackBerry'; // http://www.blackberry.com/ |
|
| 87 | - const BROWSER_ICECAT = 'IceCat'; // http://en.wikipedia.org/wiki/GNU_IceCat |
|
| 88 | - const BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // http://en.wikipedia.org/wiki/Web_Browser_for_S60 |
|
| 89 | - const BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform |
|
| 90 | - const BROWSER_MSN = 'MSN Browser'; // http://explorer.msn.com/ |
|
| 91 | - const BROWSER_MSNBOT = 'MSN Bot'; // http://search.msn.com/msnbot.htm |
|
| 92 | - const BROWSER_BINGBOT = 'Bing Bot'; // http://en.wikipedia.org/wiki/Bingbot |
|
| 93 | - |
|
| 94 | - const BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // http://browser.netscape.com/ (DEPRECATED) |
|
| 95 | - const BROWSER_GALEON = 'Galeon'; // http://galeon.sourceforge.net/ (DEPRECATED) |
|
| 96 | - const BROWSER_NETPOSITIVE = 'NetPositive'; // http://en.wikipedia.org/wiki/NetPositive (DEPRECATED) |
|
| 97 | - const BROWSER_PHOENIX = 'Phoenix'; // http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED) |
|
| 98 | - |
|
| 99 | - const PLATFORM_UNKNOWN = 'unknown'; |
|
| 100 | - const PLATFORM_WINDOWS = 'Windows'; |
|
| 101 | - const PLATFORM_WINDOWS_CE = 'Windows CE'; |
|
| 102 | - const PLATFORM_APPLE = 'Apple'; |
|
| 103 | - const PLATFORM_LINUX = 'Linux'; |
|
| 104 | - const PLATFORM_OS2 = 'OS/2'; |
|
| 105 | - const PLATFORM_BEOS = 'BeOS'; |
|
| 106 | - const PLATFORM_IPHONE = 'iPhone'; |
|
| 107 | - const PLATFORM_IPOD = 'iPod'; |
|
| 108 | - const PLATFORM_IPAD = 'iPad'; |
|
| 109 | - const PLATFORM_BLACKBERRY = 'BlackBerry'; |
|
| 110 | - const PLATFORM_NOKIA = 'Nokia'; |
|
| 111 | - const PLATFORM_FREEBSD = 'FreeBSD'; |
|
| 112 | - const PLATFORM_OPENBSD = 'OpenBSD'; |
|
| 113 | - const PLATFORM_NETBSD = 'NetBSD'; |
|
| 114 | - const PLATFORM_SUNOS = 'SunOS'; |
|
| 115 | - const PLATFORM_OPENSOLARIS = 'OpenSolaris'; |
|
| 116 | - const PLATFORM_ANDROID = 'Android'; |
|
| 117 | - |
|
| 118 | - const OPERATING_SYSTEM_UNKNOWN = 'unknown'; |
|
| 119 | - |
|
| 120 | - public function __construct($userAgent = "") |
|
| 121 | - { |
|
| 122 | - $this->reset(); |
|
| 123 | - if ($userAgent != "") { |
|
| 124 | - $this->setUserAgent($userAgent); |
|
| 125 | - } else { |
|
| 126 | - $this->determine(); |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Reset all properties |
|
| 132 | - */ |
|
| 133 | - public function reset() |
|
| 134 | - { |
|
| 135 | - $this->_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; |
|
| 136 | - $this->_browser_name = self::BROWSER_UNKNOWN; |
|
| 137 | - $this->_version = self::VERSION_UNKNOWN; |
|
| 138 | - $this->_platform = self::PLATFORM_UNKNOWN; |
|
| 139 | - $this->_os = self::OPERATING_SYSTEM_UNKNOWN; |
|
| 140 | - $this->_is_aol = false; |
|
| 141 | - $this->_is_mobile = false; |
|
| 142 | - $this->_is_tablet = false; |
|
| 143 | - $this->_is_robot = false; |
|
| 144 | - $this->_is_facebook = false; |
|
| 145 | - $this->_aol_version = self::VERSION_UNKNOWN; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Check to see if the specific browser is valid |
|
| 150 | - * @param string $browserName |
|
| 151 | - * @return bool True if the browser is the specified browser |
|
| 152 | - */ |
|
| 153 | - function isBrowser($browserName) |
|
| 154 | - { |
|
| 155 | - return (0 == strcasecmp($this->_browser_name, trim($browserName))); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * The name of the browser. All return types are from the class contants |
|
| 160 | - * @return string Name of the browser |
|
| 161 | - */ |
|
| 162 | - public function getBrowser() |
|
| 163 | - { |
|
| 164 | - return $this->_browser_name; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Set the name of the browser |
|
| 169 | - * @param $browser string The name of the Browser |
|
| 170 | - */ |
|
| 171 | - public function setBrowser($browser) |
|
| 172 | - { |
|
| 173 | - $this->_browser_name = $browser; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * The name of the platform. All return types are from the class contants |
|
| 178 | - * @return string Name of the browser |
|
| 179 | - */ |
|
| 180 | - public function getPlatform() |
|
| 181 | - { |
|
| 182 | - return $this->_platform; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Set the name of the platform |
|
| 187 | - * @param string $platform The name of the Platform |
|
| 188 | - */ |
|
| 189 | - public function setPlatform($platform) |
|
| 190 | - { |
|
| 191 | - $this->_platform = $platform; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * The version of the browser. |
|
| 196 | - * @return string Version of the browser (will only contain alpha-numeric characters and a period) |
|
| 197 | - */ |
|
| 198 | - public function getVersion() |
|
| 199 | - { |
|
| 200 | - return $this->_version; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Set the version of the browser |
|
| 205 | - * @param string $version The version of the Browser |
|
| 206 | - */ |
|
| 207 | - public function setVersion($version) |
|
| 208 | - { |
|
| 209 | - $this->_version = preg_replace('/[^0-9,.,a-z,A-Z-]/', '', $version); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - /** |
|
| 213 | - * The version of AOL. |
|
| 214 | - * @return string Version of AOL (will only contain alpha-numeric characters and a period) |
|
| 215 | - */ |
|
| 216 | - public function getAolVersion() |
|
| 217 | - { |
|
| 218 | - return $this->_aol_version; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * Set the version of AOL |
|
| 223 | - * @param string $version The version of AOL |
|
| 224 | - */ |
|
| 225 | - public function setAolVersion($version) |
|
| 226 | - { |
|
| 227 | - $this->_aol_version = preg_replace('/[^0-9,.,a-z,A-Z]/', '', $version); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Is the browser from AOL? |
|
| 232 | - * @return boolean True if the browser is from AOL otherwise false |
|
| 233 | - */ |
|
| 234 | - public function isAol() |
|
| 235 | - { |
|
| 236 | - return $this->_is_aol; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Is the browser from a mobile device? |
|
| 241 | - * @return boolean True if the browser is from a mobile device otherwise false |
|
| 242 | - */ |
|
| 243 | - public function isMobile() |
|
| 244 | - { |
|
| 245 | - return $this->_is_mobile; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * Is the browser from a tablet device? |
|
| 250 | - * @return boolean True if the browser is from a tablet device otherwise false |
|
| 251 | - */ |
|
| 252 | - public function isTablet() |
|
| 253 | - { |
|
| 254 | - return $this->_is_tablet; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * Is the browser from a robot (ex Slurp,GoogleBot)? |
|
| 259 | - * @return boolean True if the browser is from a robot otherwise false |
|
| 260 | - */ |
|
| 261 | - public function isRobot() |
|
| 262 | - { |
|
| 263 | - return $this->_is_robot; |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * Is the browser from facebook? |
|
| 268 | - * @return boolean True if the browser is from facebook otherwise false |
|
| 269 | - */ |
|
| 270 | - public function isFacebook() |
|
| 271 | - { |
|
| 272 | - return $this->_is_facebook; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * Set the browser to be from AOL |
|
| 277 | - * @param $isAol |
|
| 278 | - */ |
|
| 279 | - public function setAol($isAol) |
|
| 280 | - { |
|
| 281 | - $this->_is_aol = $isAol; |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * Set the Browser to be mobile |
|
| 286 | - * @param boolean $value is the browser a mobile browser or not |
|
| 287 | - */ |
|
| 288 | - protected function setMobile($value = true) |
|
| 289 | - { |
|
| 290 | - $this->_is_mobile = $value; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * Set the Browser to be tablet |
|
| 295 | - * @param boolean $value is the browser a tablet browser or not |
|
| 296 | - */ |
|
| 297 | - protected function setTablet($value = true) |
|
| 298 | - { |
|
| 299 | - $this->_is_tablet = $value; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * Set the Browser to be a robot |
|
| 304 | - * @param boolean $value is the browser a robot or not |
|
| 305 | - */ |
|
| 306 | - protected function setRobot($value = true) |
|
| 307 | - { |
|
| 308 | - $this->_is_robot = $value; |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * Set the Browser to be a Facebook request |
|
| 313 | - * @param boolean $value is the browser a robot or not |
|
| 314 | - */ |
|
| 315 | - protected function setFacebook($value = true) |
|
| 316 | - { |
|
| 317 | - $this->_is_facebook = $value; |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - /** |
|
| 321 | - * Get the user agent value in use to determine the browser |
|
| 322 | - * @return string The user agent from the HTTP header |
|
| 323 | - */ |
|
| 324 | - public function getUserAgent() |
|
| 325 | - { |
|
| 326 | - return $this->_agent; |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * Set the user agent value (the construction will use the HTTP header value - this will overwrite it) |
|
| 331 | - * @param string $agent_string The value for the User Agent |
|
| 332 | - */ |
|
| 333 | - public function setUserAgent($agent_string) |
|
| 334 | - { |
|
| 335 | - $this->reset(); |
|
| 336 | - $this->_agent = $agent_string; |
|
| 337 | - $this->determine(); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * Used to determine if the browser is actually "chromeframe" |
|
| 342 | - * @since 1.7 |
|
| 343 | - * @return boolean True if the browser is using chromeframe |
|
| 344 | - */ |
|
| 345 | - public function isChromeFrame() |
|
| 346 | - { |
|
| 347 | - return (strpos($this->_agent, "chromeframe") !== false); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * Returns a formatted string with a summary of the details of the browser. |
|
| 352 | - * @return string formatted string with a summary of the browser |
|
| 353 | - */ |
|
| 354 | - public function __toString() |
|
| 355 | - { |
|
| 356 | - return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
| 357 | - "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
| 358 | - "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
| 359 | - "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * Protected routine to calculate and determine what the browser is in use (including platform) |
|
| 364 | - */ |
|
| 365 | - protected function determine() |
|
| 366 | - { |
|
| 367 | - $this->checkPlatform(); |
|
| 368 | - $this->checkBrowsers(); |
|
| 369 | - $this->checkForAol(); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * Protected routine to determine the browser type |
|
| 374 | - * @return boolean True if the browser was detected otherwise false |
|
| 375 | - */ |
|
| 376 | - protected function checkBrowsers() |
|
| 377 | - { |
|
| 378 | - return ( |
|
| 379 | - // well-known, well-used |
|
| 380 | - // Special Notes: |
|
| 381 | - // (1) Opera must be checked before FireFox due to the odd |
|
| 382 | - // user agents used in some older versions of Opera |
|
| 383 | - // (2) WebTV is strapped onto Internet Explorer so we must |
|
| 384 | - // check for WebTV before IE |
|
| 385 | - // (3) (deprecated) Galeon is based on Firefox and needs to be |
|
| 386 | - // tested before Firefox is tested |
|
| 387 | - // (4) OmniWeb is based on Safari so OmniWeb check must occur |
|
| 388 | - // before Safari |
|
| 389 | - // (5) Netscape 9+ is based on Firefox so Netscape checks |
|
| 390 | - // before FireFox are necessary |
|
| 391 | - $this->checkBrowserWebTv() || |
|
| 392 | - $this->checkBrowserInternetExplorer() || |
|
| 393 | - $this->checkBrowserOpera() || |
|
| 394 | - $this->checkBrowserGaleon() || |
|
| 395 | - $this->checkBrowserNetscapeNavigator9Plus() || |
|
| 396 | - $this->checkBrowserFirefox() || |
|
| 397 | - $this->checkBrowserChrome() || |
|
| 398 | - $this->checkBrowserOmniWeb() || |
|
| 399 | - |
|
| 400 | - // common mobile |
|
| 401 | - $this->checkBrowserAndroid() || |
|
| 402 | - $this->checkBrowseriPad() || |
|
| 403 | - $this->checkBrowseriPod() || |
|
| 404 | - $this->checkBrowseriPhone() || |
|
| 405 | - $this->checkBrowserBlackBerry() || |
|
| 406 | - $this->checkBrowserNokia() || |
|
| 407 | - |
|
| 408 | - // common bots |
|
| 409 | - $this->checkBrowserGoogleBot() || |
|
| 410 | - $this->checkBrowserMSNBot() || |
|
| 411 | - $this->checkBrowserBingBot() || |
|
| 412 | - $this->checkBrowserSlurp() || |
|
| 413 | - |
|
| 414 | - // check for facebook external hit when loading URL |
|
| 415 | - $this->checkFacebookExternalHit() || |
|
| 416 | - |
|
| 417 | - // WebKit base check (post mobile and others) |
|
| 418 | - $this->checkBrowserSafari() || |
|
| 419 | - |
|
| 420 | - // everyone else |
|
| 421 | - $this->checkBrowserNetPositive() || |
|
| 422 | - $this->checkBrowserFirebird() || |
|
| 423 | - $this->checkBrowserKonqueror() || |
|
| 424 | - $this->checkBrowserIcab() || |
|
| 425 | - $this->checkBrowserPhoenix() || |
|
| 426 | - $this->checkBrowserAmaya() || |
|
| 427 | - $this->checkBrowserLynx() || |
|
| 428 | - $this->checkBrowserShiretoko() || |
|
| 429 | - $this->checkBrowserIceCat() || |
|
| 430 | - $this->checkBrowserIceweasel() || |
|
| 431 | - $this->checkBrowserW3CValidator() || |
|
| 432 | - $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */ |
|
| 433 | - ); |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * Determine if the user is using a BlackBerry (last updated 1.7) |
|
| 438 | - * @return boolean True if the browser is the BlackBerry browser otherwise false |
|
| 439 | - */ |
|
| 440 | - protected function checkBrowserBlackBerry() |
|
| 441 | - { |
|
| 442 | - if (stripos($this->_agent, 'blackberry') !== false) { |
|
| 443 | - $aresult = explode("/", stristr($this->_agent, "BlackBerry")); |
|
| 444 | - if (isset($aresult[1])) { |
|
| 445 | - $aversion = explode(' ', $aresult[1]); |
|
| 446 | - $this->setVersion($aversion[0]); |
|
| 447 | - $this->_browser_name = self::BROWSER_BLACKBERRY; |
|
| 448 | - $this->setMobile(true); |
|
| 449 | - return true; |
|
| 450 | - } |
|
| 451 | - } |
|
| 452 | - return false; |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - /** |
|
| 456 | - * Determine if the user is using an AOL User Agent (last updated 1.7) |
|
| 457 | - * @return boolean True if the browser is from AOL otherwise false |
|
| 458 | - */ |
|
| 459 | - protected function checkForAol() |
|
| 460 | - { |
|
| 461 | - $this->setAol(false); |
|
| 462 | - $this->setAolVersion(self::VERSION_UNKNOWN); |
|
| 463 | - |
|
| 464 | - if (stripos($this->_agent, 'aol') !== false) { |
|
| 465 | - $aversion = explode(' ', stristr($this->_agent, 'AOL')); |
|
| 466 | - if (isset($aversion[1])) { |
|
| 467 | - $this->setAol(true); |
|
| 468 | - $this->setAolVersion(preg_replace('/[^0-9\.a-z]/i', '', $aversion[1])); |
|
| 469 | - return true; |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - return false; |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - /** |
|
| 476 | - * Determine if the browser is the GoogleBot or not (last updated 1.7) |
|
| 477 | - * @return boolean True if the browser is the GoogletBot otherwise false |
|
| 478 | - */ |
|
| 479 | - protected function checkBrowserGoogleBot() |
|
| 480 | - { |
|
| 481 | - if (stripos($this->_agent, 'googlebot') !== false) { |
|
| 482 | - $aresult = explode('/', stristr($this->_agent, 'googlebot')); |
|
| 483 | - if (isset($aresult[1])) { |
|
| 484 | - $aversion = explode(' ', $aresult[1]); |
|
| 485 | - $this->setVersion(str_replace(';', '', $aversion[0])); |
|
| 486 | - $this->_browser_name = self::BROWSER_GOOGLEBOT; |
|
| 487 | - $this->setRobot(true); |
|
| 488 | - return true; |
|
| 489 | - } |
|
| 490 | - } |
|
| 491 | - return false; |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - /** |
|
| 495 | - * Determine if the browser is the MSNBot or not (last updated 1.9) |
|
| 496 | - * @return boolean True if the browser is the MSNBot otherwise false |
|
| 497 | - */ |
|
| 498 | - protected function checkBrowserMSNBot() |
|
| 499 | - { |
|
| 500 | - if (stripos($this->_agent, "msnbot") !== false) { |
|
| 501 | - $aresult = explode("/", stristr($this->_agent, "msnbot")); |
|
| 502 | - if (isset($aresult[1])) { |
|
| 503 | - $aversion = explode(" ", $aresult[1]); |
|
| 504 | - $this->setVersion(str_replace(";", "", $aversion[0])); |
|
| 505 | - $this->_browser_name = self::BROWSER_MSNBOT; |
|
| 506 | - $this->setRobot(true); |
|
| 507 | - return true; |
|
| 508 | - } |
|
| 509 | - } |
|
| 510 | - return false; |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - /** |
|
| 514 | - * Determine if the browser is the BingBot or not (last updated 1.9) |
|
| 515 | - * @return boolean True if the browser is the BingBot otherwise false |
|
| 516 | - */ |
|
| 517 | - protected function checkBrowserBingBot() |
|
| 518 | - { |
|
| 519 | - if (stripos($this->_agent, "bingbot") !== false) { |
|
| 520 | - $aresult = explode("/", stristr($this->_agent, "bingbot")); |
|
| 521 | - if (isset($aresult[1])) { |
|
| 522 | - $aversion = explode(" ", $aresult[1]); |
|
| 523 | - $this->setVersion(str_replace(";", "", $aversion[0])); |
|
| 524 | - $this->_browser_name = self::BROWSER_BINGBOT; |
|
| 525 | - $this->setRobot(true); |
|
| 526 | - return true; |
|
| 527 | - } |
|
| 528 | - } |
|
| 529 | - return false; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * Determine if the browser is the W3C Validator or not (last updated 1.7) |
|
| 534 | - * @return boolean True if the browser is the W3C Validator otherwise false |
|
| 535 | - */ |
|
| 536 | - protected function checkBrowserW3CValidator() |
|
| 537 | - { |
|
| 538 | - if (stripos($this->_agent, 'W3C-checklink') !== false) { |
|
| 539 | - $aresult = explode('/', stristr($this->_agent, 'W3C-checklink')); |
|
| 540 | - if (isset($aresult[1])) { |
|
| 541 | - $aversion = explode(' ', $aresult[1]); |
|
| 542 | - $this->setVersion($aversion[0]); |
|
| 543 | - $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 544 | - return true; |
|
| 545 | - } |
|
| 546 | - } else if (stripos($this->_agent, 'W3C_Validator') !== false) { |
|
| 547 | - // Some of the Validator versions do not delineate w/ a slash - add it back in |
|
| 548 | - $ua = str_replace("W3C_Validator ", "W3C_Validator/", $this->_agent); |
|
| 549 | - $aresult = explode('/', stristr($ua, 'W3C_Validator')); |
|
| 550 | - if (isset($aresult[1])) { |
|
| 551 | - $aversion = explode(' ', $aresult[1]); |
|
| 552 | - $this->setVersion($aversion[0]); |
|
| 553 | - $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 554 | - return true; |
|
| 555 | - } |
|
| 556 | - } else if (stripos($this->_agent, 'W3C-mobileOK') !== false) { |
|
| 557 | - $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 558 | - $this->setMobile(true); |
|
| 559 | - return true; |
|
| 560 | - } |
|
| 561 | - return false; |
|
| 562 | - } |
|
| 563 | - |
|
| 564 | - /** |
|
| 565 | - * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7) |
|
| 566 | - * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false |
|
| 567 | - */ |
|
| 568 | - protected function checkBrowserSlurp() |
|
| 569 | - { |
|
| 570 | - if (stripos($this->_agent, 'slurp') !== false) { |
|
| 571 | - $aresult = explode('/', stristr($this->_agent, 'Slurp')); |
|
| 572 | - if (isset($aresult[1])) { |
|
| 573 | - $aversion = explode(' ', $aresult[1]); |
|
| 574 | - $this->setVersion($aversion[0]); |
|
| 575 | - $this->_browser_name = self::BROWSER_SLURP; |
|
| 576 | - $this->setRobot(true); |
|
| 577 | - $this->setMobile(false); |
|
| 578 | - return true; |
|
| 579 | - } |
|
| 580 | - } |
|
| 581 | - return false; |
|
| 582 | - } |
|
| 583 | - |
|
| 584 | - /** |
|
| 585 | - * Determine if the browser is Internet Explorer or not (last updated 1.7) |
|
| 586 | - * @return boolean True if the browser is Internet Explorer otherwise false |
|
| 587 | - */ |
|
| 588 | - protected function checkBrowserInternetExplorer() |
|
| 589 | - { |
|
| 590 | - // Test for IE11 |
|
| 591 | - if (stripos($this->_agent, 'Trident/7.0; rv:11.0') !== false) { |
|
| 592 | - $this->setBrowser(self::BROWSER_IE); |
|
| 593 | - $this->setVersion('11.0'); |
|
| 594 | - return true; |
|
| 595 | - } // Test for v1 - v1.5 IE |
|
| 596 | - else if (stripos($this->_agent, 'microsoft internet explorer') !== false) { |
|
| 597 | - $this->setBrowser(self::BROWSER_IE); |
|
| 598 | - $this->setVersion('1.0'); |
|
| 599 | - $aresult = stristr($this->_agent, '/'); |
|
| 600 | - if (preg_match('/308|425|426|474|0b1/i', $aresult)) { |
|
| 601 | - $this->setVersion('1.5'); |
|
| 602 | - } |
|
| 603 | - return true; |
|
| 604 | - } // Test for versions > 1.5 |
|
| 605 | - else if (stripos($this->_agent, 'msie') !== false && stripos($this->_agent, 'opera') === false) { |
|
| 606 | - // See if the browser is the odd MSN Explorer |
|
| 607 | - if (stripos($this->_agent, 'msnb') !== false) { |
|
| 608 | - $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'MSN')); |
|
| 609 | - if (isset($aresult[1])) { |
|
| 610 | - $this->setBrowser(self::BROWSER_MSN); |
|
| 611 | - $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
|
| 612 | - return true; |
|
| 613 | - } |
|
| 614 | - } |
|
| 615 | - $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie')); |
|
| 616 | - if (isset($aresult[1])) { |
|
| 617 | - $this->setBrowser(self::BROWSER_IE); |
|
| 618 | - $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
|
| 619 | - if (stripos($this->_agent, 'IEMobile') !== false) { |
|
| 620 | - $this->setBrowser(self::BROWSER_POCKET_IE); |
|
| 621 | - $this->setMobile(true); |
|
| 622 | - } |
|
| 623 | - return true; |
|
| 624 | - } |
|
| 625 | - } // Test for versions > IE 10 |
|
| 626 | - else if (stripos($this->_agent, 'trident') !== false) { |
|
| 627 | - $this->setBrowser(self::BROWSER_IE); |
|
| 628 | - $result = explode('rv:', $this->_agent); |
|
| 629 | - if (isset($result[1])) { |
|
| 630 | - $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
|
| 631 | - $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); |
|
| 632 | - } |
|
| 633 | - } // Test for Pocket IE |
|
| 634 | - else if (stripos($this->_agent, 'mspie') !== false || stripos($this->_agent, 'pocket') !== false) { |
|
| 635 | - $aresult = explode(' ', stristr($this->_agent, 'mspie')); |
|
| 636 | - if (isset($aresult[1])) { |
|
| 637 | - $this->setPlatform(self::PLATFORM_WINDOWS_CE); |
|
| 638 | - $this->setBrowser(self::BROWSER_POCKET_IE); |
|
| 639 | - $this->setMobile(true); |
|
| 640 | - |
|
| 641 | - if (stripos($this->_agent, 'mspie') !== false) { |
|
| 642 | - $this->setVersion($aresult[1]); |
|
| 643 | - } else { |
|
| 644 | - $aversion = explode('/', $this->_agent); |
|
| 645 | - if (isset($aversion[1])) { |
|
| 646 | - $this->setVersion($aversion[1]); |
|
| 647 | - } |
|
| 648 | - } |
|
| 649 | - return true; |
|
| 650 | - } |
|
| 651 | - } |
|
| 652 | - return false; |
|
| 653 | - } |
|
| 654 | - |
|
| 655 | - /** |
|
| 656 | - * Determine if the browser is Opera or not (last updated 1.7) |
|
| 657 | - * @return boolean True if the browser is Opera otherwise false |
|
| 658 | - */ |
|
| 659 | - protected function checkBrowserOpera() |
|
| 660 | - { |
|
| 661 | - if (stripos($this->_agent, 'opera mini') !== false) { |
|
| 662 | - $resultant = stristr($this->_agent, 'opera mini'); |
|
| 663 | - if (preg_match('/\//', $resultant)) { |
|
| 664 | - $aresult = explode('/', $resultant); |
|
| 665 | - if (isset($aresult[1])) { |
|
| 666 | - $aversion = explode(' ', $aresult[1]); |
|
| 667 | - $this->setVersion($aversion[0]); |
|
| 668 | - } |
|
| 669 | - } else { |
|
| 670 | - $aversion = explode(' ', stristr($resultant, 'opera mini')); |
|
| 671 | - if (isset($aversion[1])) { |
|
| 672 | - $this->setVersion($aversion[1]); |
|
| 673 | - } |
|
| 674 | - } |
|
| 675 | - $this->_browser_name = self::BROWSER_OPERA_MINI; |
|
| 676 | - $this->setMobile(true); |
|
| 677 | - return true; |
|
| 678 | - } else if (stripos($this->_agent, 'opera') !== false) { |
|
| 679 | - $resultant = stristr($this->_agent, 'opera'); |
|
| 680 | - if (preg_match('/Version\/(1*.*)$/', $resultant, $matches)) { |
|
| 681 | - $this->setVersion($matches[1]); |
|
| 682 | - } else if (preg_match('/\//', $resultant)) { |
|
| 683 | - $aresult = explode('/', str_replace("(", " ", $resultant)); |
|
| 684 | - if (isset($aresult[1])) { |
|
| 685 | - $aversion = explode(' ', $aresult[1]); |
|
| 686 | - $this->setVersion($aversion[0]); |
|
| 687 | - } |
|
| 688 | - } else { |
|
| 689 | - $aversion = explode(' ', stristr($resultant, 'opera')); |
|
| 690 | - $this->setVersion(isset($aversion[1]) ? $aversion[1] : ""); |
|
| 691 | - } |
|
| 692 | - if (stripos($this->_agent, 'Opera Mobi') !== false) { |
|
| 693 | - $this->setMobile(true); |
|
| 694 | - } |
|
| 695 | - $this->_browser_name = self::BROWSER_OPERA; |
|
| 696 | - return true; |
|
| 697 | - } else if (stripos($this->_agent, 'OPR') !== false) { |
|
| 698 | - $resultant = stristr($this->_agent, 'OPR'); |
|
| 699 | - if (preg_match('/\//', $resultant)) { |
|
| 700 | - $aresult = explode('/', str_replace("(", " ", $resultant)); |
|
| 701 | - if (isset($aresult[1])) { |
|
| 702 | - $aversion = explode(' ', $aresult[1]); |
|
| 703 | - $this->setVersion($aversion[0]); |
|
| 704 | - } |
|
| 705 | - } |
|
| 706 | - if (stripos($this->_agent, 'Mobile') !== false) { |
|
| 707 | - $this->setMobile(true); |
|
| 708 | - } |
|
| 709 | - $this->_browser_name = self::BROWSER_OPERA; |
|
| 710 | - return true; |
|
| 711 | - } |
|
| 712 | - return false; |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - /** |
|
| 716 | - * Determine if the browser is Chrome or not (last updated 1.7) |
|
| 717 | - * @return boolean True if the browser is Chrome otherwise false |
|
| 718 | - */ |
|
| 719 | - protected function checkBrowserChrome() |
|
| 720 | - { |
|
| 721 | - if (stripos($this->_agent, 'Chrome') !== false) { |
|
| 722 | - $aresult = explode('/', stristr($this->_agent, 'Chrome')); |
|
| 723 | - if (isset($aresult[1])) { |
|
| 724 | - $aversion = explode(' ', $aresult[1]); |
|
| 725 | - $this->setVersion($aversion[0]); |
|
| 726 | - $this->setBrowser(self::BROWSER_CHROME); |
|
| 727 | - //Chrome on Android |
|
| 728 | - if (stripos($this->_agent, 'Android') !== false) { |
|
| 729 | - if (stripos($this->_agent, 'Mobile') !== false) { |
|
| 730 | - $this->setMobile(true); |
|
| 731 | - } else { |
|
| 732 | - $this->setTablet(true); |
|
| 733 | - } |
|
| 734 | - } |
|
| 735 | - return true; |
|
| 736 | - } |
|
| 737 | - } |
|
| 738 | - return false; |
|
| 739 | - } |
|
| 740 | - |
|
| 741 | - |
|
| 742 | - /** |
|
| 743 | - * Determine if the browser is WebTv or not (last updated 1.7) |
|
| 744 | - * @return boolean True if the browser is WebTv otherwise false |
|
| 745 | - */ |
|
| 746 | - protected function checkBrowserWebTv() |
|
| 747 | - { |
|
| 748 | - if (stripos($this->_agent, 'webtv') !== false) { |
|
| 749 | - $aresult = explode('/', stristr($this->_agent, 'webtv')); |
|
| 750 | - if (isset($aresult[1])) { |
|
| 751 | - $aversion = explode(' ', $aresult[1]); |
|
| 752 | - $this->setVersion($aversion[0]); |
|
| 753 | - $this->setBrowser(self::BROWSER_WEBTV); |
|
| 754 | - return true; |
|
| 755 | - } |
|
| 756 | - } |
|
| 757 | - return false; |
|
| 758 | - } |
|
| 759 | - |
|
| 760 | - /** |
|
| 761 | - * Determine if the browser is NetPositive or not (last updated 1.7) |
|
| 762 | - * @return boolean True if the browser is NetPositive otherwise false |
|
| 763 | - */ |
|
| 764 | - protected function checkBrowserNetPositive() |
|
| 765 | - { |
|
| 766 | - if (stripos($this->_agent, 'NetPositive') !== false) { |
|
| 767 | - $aresult = explode('/', stristr($this->_agent, 'NetPositive')); |
|
| 768 | - if (isset($aresult[1])) { |
|
| 769 | - $aversion = explode(' ', $aresult[1]); |
|
| 770 | - $this->setVersion(str_replace(array('(', ')', ';'), '', $aversion[0])); |
|
| 771 | - $this->setBrowser(self::BROWSER_NETPOSITIVE); |
|
| 772 | - return true; |
|
| 773 | - } |
|
| 774 | - } |
|
| 775 | - return false; |
|
| 776 | - } |
|
| 777 | - |
|
| 778 | - /** |
|
| 779 | - * Determine if the browser is Galeon or not (last updated 1.7) |
|
| 780 | - * @return boolean True if the browser is Galeon otherwise false |
|
| 781 | - */ |
|
| 782 | - protected function checkBrowserGaleon() |
|
| 783 | - { |
|
| 784 | - if (stripos($this->_agent, 'galeon') !== false) { |
|
| 785 | - $aresult = explode(' ', stristr($this->_agent, 'galeon')); |
|
| 786 | - $aversion = explode('/', $aresult[0]); |
|
| 787 | - if (isset($aversion[1])) { |
|
| 788 | - $this->setVersion($aversion[1]); |
|
| 789 | - $this->setBrowser(self::BROWSER_GALEON); |
|
| 790 | - return true; |
|
| 791 | - } |
|
| 792 | - } |
|
| 793 | - return false; |
|
| 794 | - } |
|
| 795 | - |
|
| 796 | - /** |
|
| 797 | - * Determine if the browser is Konqueror or not (last updated 1.7) |
|
| 798 | - * @return boolean True if the browser is Konqueror otherwise false |
|
| 799 | - */ |
|
| 800 | - protected function checkBrowserKonqueror() |
|
| 801 | - { |
|
| 802 | - if (stripos($this->_agent, 'Konqueror') !== false) { |
|
| 803 | - $aresult = explode(' ', stristr($this->_agent, 'Konqueror')); |
|
| 804 | - $aversion = explode('/', $aresult[0]); |
|
| 805 | - if (isset($aversion[1])) { |
|
| 806 | - $this->setVersion($aversion[1]); |
|
| 807 | - $this->setBrowser(self::BROWSER_KONQUEROR); |
|
| 808 | - return true; |
|
| 809 | - } |
|
| 810 | - } |
|
| 811 | - return false; |
|
| 812 | - } |
|
| 813 | - |
|
| 814 | - /** |
|
| 815 | - * Determine if the browser is iCab or not (last updated 1.7) |
|
| 816 | - * @return boolean True if the browser is iCab otherwise false |
|
| 817 | - */ |
|
| 818 | - protected function checkBrowserIcab() |
|
| 819 | - { |
|
| 820 | - if (stripos($this->_agent, 'icab') !== false) { |
|
| 821 | - $aversion = explode(' ', stristr(str_replace('/', ' ', $this->_agent), 'icab')); |
|
| 822 | - if (isset($aversion[1])) { |
|
| 823 | - $this->setVersion($aversion[1]); |
|
| 824 | - $this->setBrowser(self::BROWSER_ICAB); |
|
| 825 | - return true; |
|
| 826 | - } |
|
| 827 | - } |
|
| 828 | - return false; |
|
| 829 | - } |
|
| 830 | - |
|
| 831 | - /** |
|
| 832 | - * Determine if the browser is OmniWeb or not (last updated 1.7) |
|
| 833 | - * @return boolean True if the browser is OmniWeb otherwise false |
|
| 834 | - */ |
|
| 835 | - protected function checkBrowserOmniWeb() |
|
| 836 | - { |
|
| 837 | - if (stripos($this->_agent, 'omniweb') !== false) { |
|
| 838 | - $aresult = explode('/', stristr($this->_agent, 'omniweb')); |
|
| 839 | - $aversion = explode(' ', isset($aresult[1]) ? $aresult[1] : ""); |
|
| 840 | - $this->setVersion($aversion[0]); |
|
| 841 | - $this->setBrowser(self::BROWSER_OMNIWEB); |
|
| 842 | - return true; |
|
| 843 | - } |
|
| 844 | - return false; |
|
| 845 | - } |
|
| 846 | - |
|
| 847 | - /** |
|
| 848 | - * Determine if the browser is Phoenix or not (last updated 1.7) |
|
| 849 | - * @return boolean True if the browser is Phoenix otherwise false |
|
| 850 | - */ |
|
| 851 | - protected function checkBrowserPhoenix() |
|
| 852 | - { |
|
| 853 | - if (stripos($this->_agent, 'Phoenix') !== false) { |
|
| 854 | - $aversion = explode('/', stristr($this->_agent, 'Phoenix')); |
|
| 855 | - if (isset($aversion[1])) { |
|
| 856 | - $this->setVersion($aversion[1]); |
|
| 857 | - $this->setBrowser(self::BROWSER_PHOENIX); |
|
| 858 | - return true; |
|
| 859 | - } |
|
| 860 | - } |
|
| 861 | - return false; |
|
| 862 | - } |
|
| 863 | - |
|
| 864 | - /** |
|
| 865 | - * Determine if the browser is Firebird or not (last updated 1.7) |
|
| 866 | - * @return boolean True if the browser is Firebird otherwise false |
|
| 867 | - */ |
|
| 868 | - protected function checkBrowserFirebird() |
|
| 869 | - { |
|
| 870 | - if (stripos($this->_agent, 'Firebird') !== false) { |
|
| 871 | - $aversion = explode('/', stristr($this->_agent, 'Firebird')); |
|
| 872 | - if (isset($aversion[1])) { |
|
| 873 | - $this->setVersion($aversion[1]); |
|
| 874 | - $this->setBrowser(self::BROWSER_FIREBIRD); |
|
| 875 | - return true; |
|
| 876 | - } |
|
| 877 | - } |
|
| 878 | - return false; |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - /** |
|
| 882 | - * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7) |
|
| 883 | - * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008) |
|
| 884 | - * @return boolean True if the browser is Netscape Navigator 9+ otherwise false |
|
| 885 | - */ |
|
| 886 | - protected function checkBrowserNetscapeNavigator9Plus() |
|
| 887 | - { |
|
| 888 | - if (stripos($this->_agent, 'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i', $this->_agent, $matches)) { |
|
| 889 | - $this->setVersion($matches[1]); |
|
| 890 | - $this->setBrowser(self::BROWSER_NETSCAPE_NAVIGATOR); |
|
| 891 | - return true; |
|
| 892 | - } else if (stripos($this->_agent, 'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i', $this->_agent, $matches)) { |
|
| 893 | - $this->setVersion($matches[1]); |
|
| 894 | - $this->setBrowser(self::BROWSER_NETSCAPE_NAVIGATOR); |
|
| 895 | - return true; |
|
| 896 | - } |
|
| 897 | - return false; |
|
| 898 | - } |
|
| 899 | - |
|
| 900 | - /** |
|
| 901 | - * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7) |
|
| 902 | - * @return boolean True if the browser is Shiretoko otherwise false |
|
| 903 | - */ |
|
| 904 | - protected function checkBrowserShiretoko() |
|
| 905 | - { |
|
| 906 | - if (stripos($this->_agent, 'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i', $this->_agent, $matches)) { |
|
| 907 | - $this->setVersion($matches[1]); |
|
| 908 | - $this->setBrowser(self::BROWSER_SHIRETOKO); |
|
| 909 | - return true; |
|
| 910 | - } |
|
| 911 | - return false; |
|
| 912 | - } |
|
| 913 | - |
|
| 914 | - /** |
|
| 915 | - * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7) |
|
| 916 | - * @return boolean True if the browser is Ice Cat otherwise false |
|
| 917 | - */ |
|
| 918 | - protected function checkBrowserIceCat() |
|
| 919 | - { |
|
| 920 | - if (stripos($this->_agent, 'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i', $this->_agent, $matches)) { |
|
| 921 | - $this->setVersion($matches[1]); |
|
| 922 | - $this->setBrowser(self::BROWSER_ICECAT); |
|
| 923 | - return true; |
|
| 924 | - } |
|
| 925 | - return false; |
|
| 926 | - } |
|
| 927 | - |
|
| 928 | - /** |
|
| 929 | - * Determine if the browser is Nokia or not (last updated 1.7) |
|
| 930 | - * @return boolean True if the browser is Nokia otherwise false |
|
| 931 | - */ |
|
| 932 | - protected function checkBrowserNokia() |
|
| 933 | - { |
|
| 934 | - if (preg_match("/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches)) { |
|
| 935 | - $this->setVersion($matches[2]); |
|
| 936 | - if (stripos($this->_agent, 'Series60') !== false || strpos($this->_agent, 'S60') !== false) { |
|
| 937 | - $this->setBrowser(self::BROWSER_NOKIA_S60); |
|
| 938 | - } else { |
|
| 939 | - $this->setBrowser(self::BROWSER_NOKIA); |
|
| 940 | - } |
|
| 941 | - $this->setMobile(true); |
|
| 942 | - return true; |
|
| 943 | - } |
|
| 944 | - return false; |
|
| 945 | - } |
|
| 946 | - |
|
| 947 | - /** |
|
| 948 | - * Determine if the browser is Firefox or not (last updated 1.7) |
|
| 949 | - * @return boolean True if the browser is Firefox otherwise false |
|
| 950 | - */ |
|
| 951 | - protected function checkBrowserFirefox() |
|
| 952 | - { |
|
| 953 | - if (stripos($this->_agent, 'safari') === false) { |
|
| 954 | - if (preg_match("/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches)) { |
|
| 955 | - $this->setVersion($matches[1]); |
|
| 956 | - $this->setBrowser(self::BROWSER_FIREFOX); |
|
| 957 | - //Firefox on Android |
|
| 958 | - if (stripos($this->_agent, 'Android') !== false) { |
|
| 959 | - if (stripos($this->_agent, 'Mobile') !== false) { |
|
| 960 | - $this->setMobile(true); |
|
| 961 | - } else { |
|
| 962 | - $this->setTablet(true); |
|
| 963 | - } |
|
| 964 | - } |
|
| 965 | - return true; |
|
| 966 | - } else if (preg_match("/Firefox$/i", $this->_agent, $matches)) { |
|
| 967 | - $this->setVersion(""); |
|
| 968 | - $this->setBrowser(self::BROWSER_FIREFOX); |
|
| 969 | - return true; |
|
| 970 | - } |
|
| 971 | - } |
|
| 972 | - return false; |
|
| 973 | - } |
|
| 974 | - |
|
| 975 | - /** |
|
| 976 | - * Determine if the browser is Firefox or not (last updated 1.7) |
|
| 977 | - * @return boolean True if the browser is Firefox otherwise false |
|
| 978 | - */ |
|
| 979 | - protected function checkBrowserIceweasel() |
|
| 980 | - { |
|
| 981 | - if (stripos($this->_agent, 'Iceweasel') !== false) { |
|
| 982 | - $aresult = explode('/', stristr($this->_agent, 'Iceweasel')); |
|
| 983 | - if (isset($aresult[1])) { |
|
| 984 | - $aversion = explode(' ', $aresult[1]); |
|
| 985 | - $this->setVersion($aversion[0]); |
|
| 986 | - $this->setBrowser(self::BROWSER_ICEWEASEL); |
|
| 987 | - return true; |
|
| 988 | - } |
|
| 989 | - } |
|
| 990 | - return false; |
|
| 991 | - } |
|
| 992 | - |
|
| 993 | - /** |
|
| 994 | - * Determine if the browser is Mozilla or not (last updated 1.7) |
|
| 995 | - * @return boolean True if the browser is Mozilla otherwise false |
|
| 996 | - */ |
|
| 997 | - protected function checkBrowserMozilla() |
|
| 998 | - { |
|
| 999 | - if (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) { |
|
| 1000 | - $aversion = explode(' ', stristr($this->_agent, 'rv:')); |
|
| 1001 | - preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion); |
|
| 1002 | - $this->setVersion(str_replace('rv:', '', $aversion[0])); |
|
| 1003 | - $this->setBrowser(self::BROWSER_MOZILLA); |
|
| 1004 | - return true; |
|
| 1005 | - } else if (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) { |
|
| 1006 | - $aversion = explode('', stristr($this->_agent, 'rv:')); |
|
| 1007 | - $this->setVersion(str_replace('rv:', '', $aversion[0])); |
|
| 1008 | - $this->setBrowser(self::BROWSER_MOZILLA); |
|
| 1009 | - return true; |
|
| 1010 | - } else if (stripos($this->_agent, 'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i', $this->_agent, $matches) && stripos($this->_agent, 'netscape') === false) { |
|
| 1011 | - $this->setVersion($matches[1]); |
|
| 1012 | - $this->setBrowser(self::BROWSER_MOZILLA); |
|
| 1013 | - return true; |
|
| 1014 | - } |
|
| 1015 | - return false; |
|
| 1016 | - } |
|
| 1017 | - |
|
| 1018 | - /** |
|
| 1019 | - * Determine if the browser is Lynx or not (last updated 1.7) |
|
| 1020 | - * @return boolean True if the browser is Lynx otherwise false |
|
| 1021 | - */ |
|
| 1022 | - protected function checkBrowserLynx() |
|
| 1023 | - { |
|
| 1024 | - if (stripos($this->_agent, 'lynx') !== false) { |
|
| 1025 | - $aresult = explode('/', stristr($this->_agent, 'Lynx')); |
|
| 1026 | - $aversion = explode(' ', (isset($aresult[1]) ? $aresult[1] : "")); |
|
| 1027 | - $this->setVersion($aversion[0]); |
|
| 1028 | - $this->setBrowser(self::BROWSER_LYNX); |
|
| 1029 | - return true; |
|
| 1030 | - } |
|
| 1031 | - return false; |
|
| 1032 | - } |
|
| 1033 | - |
|
| 1034 | - /** |
|
| 1035 | - * Determine if the browser is Amaya or not (last updated 1.7) |
|
| 1036 | - * @return boolean True if the browser is Amaya otherwise false |
|
| 1037 | - */ |
|
| 1038 | - protected function checkBrowserAmaya() |
|
| 1039 | - { |
|
| 1040 | - if (stripos($this->_agent, 'amaya') !== false) { |
|
| 1041 | - $aresult = explode('/', stristr($this->_agent, 'Amaya')); |
|
| 1042 | - if (isset($aresult[1])) { |
|
| 1043 | - $aversion = explode(' ', $aresult[1]); |
|
| 1044 | - $this->setVersion($aversion[0]); |
|
| 1045 | - $this->setBrowser(self::BROWSER_AMAYA); |
|
| 1046 | - return true; |
|
| 1047 | - } |
|
| 1048 | - } |
|
| 1049 | - return false; |
|
| 1050 | - } |
|
| 1051 | - |
|
| 1052 | - /** |
|
| 1053 | - * Determine if the browser is Safari or not (last updated 1.7) |
|
| 1054 | - * @return boolean True if the browser is Safari otherwise false |
|
| 1055 | - */ |
|
| 1056 | - protected function checkBrowserSafari() |
|
| 1057 | - { |
|
| 1058 | - if (stripos($this->_agent, 'Safari') !== false |
|
| 1059 | - && stripos($this->_agent, 'iPhone') === false |
|
| 1060 | - && stripos($this->_agent, 'iPod') === false |
|
| 1061 | - ) { |
|
| 1062 | - |
|
| 1063 | - $aresult = explode('/', stristr($this->_agent, 'Version')); |
|
| 1064 | - if (isset($aresult[1])) { |
|
| 1065 | - $aversion = explode(' ', $aresult[1]); |
|
| 1066 | - $this->setVersion($aversion[0]); |
|
| 1067 | - } else { |
|
| 1068 | - $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1069 | - } |
|
| 1070 | - $this->setBrowser(self::BROWSER_SAFARI); |
|
| 1071 | - return true; |
|
| 1072 | - } |
|
| 1073 | - return false; |
|
| 1074 | - } |
|
| 1075 | - |
|
| 1076 | - /** |
|
| 1077 | - * Detect if URL is loaded from FacebookExternalHit |
|
| 1078 | - * @return boolean True if it detects FacebookExternalHit otherwise false |
|
| 1079 | - */ |
|
| 1080 | - protected function checkFacebookExternalHit() |
|
| 1081 | - { |
|
| 1082 | - if (stristr($this->_agent, 'FacebookExternalHit')) { |
|
| 1083 | - $this->setRobot(true); |
|
| 1084 | - $this->setFacebook(true); |
|
| 1085 | - return true; |
|
| 1086 | - } |
|
| 1087 | - return false; |
|
| 1088 | - } |
|
| 1089 | - |
|
| 1090 | - /** |
|
| 1091 | - * Detect if URL is being loaded from internal Facebook browser |
|
| 1092 | - * @return boolean True if it detects internal Facebook browser otherwise false |
|
| 1093 | - */ |
|
| 1094 | - protected function checkForFacebookIos() |
|
| 1095 | - { |
|
| 1096 | - if (stristr($this->_agent, 'FBIOS')) { |
|
| 1097 | - $this->setFacebook(true); |
|
| 1098 | - return true; |
|
| 1099 | - } |
|
| 1100 | - return false; |
|
| 1101 | - } |
|
| 1102 | - |
|
| 1103 | - /** |
|
| 1104 | - * Detect Version for the Safari browser on iOS devices |
|
| 1105 | - * @return boolean True if it detects the version correctly otherwise false |
|
| 1106 | - */ |
|
| 1107 | - protected function getSafariVersionOnIos() |
|
| 1108 | - { |
|
| 1109 | - $aresult = explode('/', stristr($this->_agent, 'Version')); |
|
| 1110 | - if (isset($aresult[1])) { |
|
| 1111 | - $aversion = explode(' ', $aresult[1]); |
|
| 1112 | - $this->setVersion($aversion[0]); |
|
| 1113 | - return true; |
|
| 1114 | - } |
|
| 1115 | - return false; |
|
| 1116 | - } |
|
| 1117 | - |
|
| 1118 | - /** |
|
| 1119 | - * Detect Version for the Chrome browser on iOS devices |
|
| 1120 | - * @return boolean True if it detects the version correctly otherwise false |
|
| 1121 | - */ |
|
| 1122 | - protected function getChromeVersionOnIos() |
|
| 1123 | - { |
|
| 1124 | - $aresult = explode('/', stristr($this->_agent, 'CriOS')); |
|
| 1125 | - if (isset($aresult[1])) { |
|
| 1126 | - $aversion = explode(' ', $aresult[1]); |
|
| 1127 | - $this->setVersion($aversion[0]); |
|
| 1128 | - $this->setBrowser(self::BROWSER_CHROME); |
|
| 1129 | - return true; |
|
| 1130 | - } |
|
| 1131 | - return false; |
|
| 1132 | - } |
|
| 1133 | - |
|
| 1134 | - /** |
|
| 1135 | - * Determine if the browser is iPhone or not (last updated 1.7) |
|
| 1136 | - * @return boolean True if the browser is iPhone otherwise false |
|
| 1137 | - */ |
|
| 1138 | - protected function checkBrowseriPhone() |
|
| 1139 | - { |
|
| 1140 | - if (stripos($this->_agent, 'iPhone') !== false) { |
|
| 1141 | - $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1142 | - $this->setBrowser(self::BROWSER_IPHONE); |
|
| 1143 | - $this->getSafariVersionOnIos(); |
|
| 1144 | - $this->getChromeVersionOnIos(); |
|
| 1145 | - $this->checkForFacebookIos(); |
|
| 1146 | - $this->setMobile(true); |
|
| 1147 | - return true; |
|
| 1148 | - } |
|
| 1149 | - return false; |
|
| 1150 | - } |
|
| 1151 | - |
|
| 1152 | - /** |
|
| 1153 | - * Determine if the browser is iPad or not (last updated 1.7) |
|
| 1154 | - * @return boolean True if the browser is iPad otherwise false |
|
| 1155 | - */ |
|
| 1156 | - protected function checkBrowseriPad() |
|
| 1157 | - { |
|
| 1158 | - if (stripos($this->_agent, 'iPad') !== false) { |
|
| 1159 | - $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1160 | - $this->setBrowser(self::BROWSER_IPAD); |
|
| 1161 | - $this->getSafariVersionOnIos(); |
|
| 1162 | - $this->getChromeVersionOnIos(); |
|
| 1163 | - $this->checkForFacebookIos(); |
|
| 1164 | - $this->setTablet(true); |
|
| 1165 | - return true; |
|
| 1166 | - } |
|
| 1167 | - return false; |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - /** |
|
| 1171 | - * Determine if the browser is iPod or not (last updated 1.7) |
|
| 1172 | - * @return boolean True if the browser is iPod otherwise false |
|
| 1173 | - */ |
|
| 1174 | - protected function checkBrowseriPod() |
|
| 1175 | - { |
|
| 1176 | - if (stripos($this->_agent, 'iPod') !== false) { |
|
| 1177 | - $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1178 | - $this->setBrowser(self::BROWSER_IPOD); |
|
| 1179 | - $this->getSafariVersionOnIos(); |
|
| 1180 | - $this->getChromeVersionOnIos(); |
|
| 1181 | - $this->checkForFacebookIos(); |
|
| 1182 | - $this->setMobile(true); |
|
| 1183 | - return true; |
|
| 1184 | - } |
|
| 1185 | - return false; |
|
| 1186 | - } |
|
| 1187 | - |
|
| 1188 | - /** |
|
| 1189 | - * Determine if the browser is Android or not (last updated 1.7) |
|
| 1190 | - * @return boolean True if the browser is Android otherwise false |
|
| 1191 | - */ |
|
| 1192 | - protected function checkBrowserAndroid() |
|
| 1193 | - { |
|
| 1194 | - if (stripos($this->_agent, 'Android') !== false) { |
|
| 1195 | - $aresult = explode(' ', stristr($this->_agent, 'Android')); |
|
| 1196 | - if (isset($aresult[1])) { |
|
| 1197 | - $aversion = explode(' ', $aresult[1]); |
|
| 1198 | - $this->setVersion($aversion[0]); |
|
| 1199 | - } else { |
|
| 1200 | - $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1201 | - } |
|
| 1202 | - if (stripos($this->_agent, 'Mobile') !== false) { |
|
| 1203 | - $this->setMobile(true); |
|
| 1204 | - } else { |
|
| 1205 | - $this->setTablet(true); |
|
| 1206 | - } |
|
| 1207 | - $this->setBrowser(self::BROWSER_ANDROID); |
|
| 1208 | - return true; |
|
| 1209 | - } |
|
| 1210 | - return false; |
|
| 1211 | - } |
|
| 1212 | - |
|
| 1213 | - /** |
|
| 1214 | - * Determine the user's platform (last updated 1.7) |
|
| 1215 | - */ |
|
| 1216 | - protected function checkPlatform() |
|
| 1217 | - { |
|
| 1218 | - if (stripos($this->_agent, 'windows') !== false) { |
|
| 1219 | - $this->_platform = self::PLATFORM_WINDOWS; |
|
| 1220 | - } else if (stripos($this->_agent, 'iPad') !== false) { |
|
| 1221 | - $this->_platform = self::PLATFORM_IPAD; |
|
| 1222 | - } else if (stripos($this->_agent, 'iPod') !== false) { |
|
| 1223 | - $this->_platform = self::PLATFORM_IPOD; |
|
| 1224 | - } else if (stripos($this->_agent, 'iPhone') !== false) { |
|
| 1225 | - $this->_platform = self::PLATFORM_IPHONE; |
|
| 1226 | - } elseif (stripos($this->_agent, 'mac') !== false) { |
|
| 1227 | - $this->_platform = self::PLATFORM_APPLE; |
|
| 1228 | - } elseif (stripos($this->_agent, 'android') !== false) { |
|
| 1229 | - $this->_platform = self::PLATFORM_ANDROID; |
|
| 1230 | - } elseif (stripos($this->_agent, 'linux') !== false) { |
|
| 1231 | - $this->_platform = self::PLATFORM_LINUX; |
|
| 1232 | - } else if (stripos($this->_agent, 'Nokia') !== false) { |
|
| 1233 | - $this->_platform = self::PLATFORM_NOKIA; |
|
| 1234 | - } else if (stripos($this->_agent, 'BlackBerry') !== false) { |
|
| 1235 | - $this->_platform = self::PLATFORM_BLACKBERRY; |
|
| 1236 | - } elseif (stripos($this->_agent, 'FreeBSD') !== false) { |
|
| 1237 | - $this->_platform = self::PLATFORM_FREEBSD; |
|
| 1238 | - } elseif (stripos($this->_agent, 'OpenBSD') !== false) { |
|
| 1239 | - $this->_platform = self::PLATFORM_OPENBSD; |
|
| 1240 | - } elseif (stripos($this->_agent, 'NetBSD') !== false) { |
|
| 1241 | - $this->_platform = self::PLATFORM_NETBSD; |
|
| 1242 | - } elseif (stripos($this->_agent, 'OpenSolaris') !== false) { |
|
| 1243 | - $this->_platform = self::PLATFORM_OPENSOLARIS; |
|
| 1244 | - } elseif (stripos($this->_agent, 'SunOS') !== false) { |
|
| 1245 | - $this->_platform = self::PLATFORM_SUNOS; |
|
| 1246 | - } elseif (stripos($this->_agent, 'OS\/2') !== false) { |
|
| 1247 | - $this->_platform = self::PLATFORM_OS2; |
|
| 1248 | - } elseif (stripos($this->_agent, 'BeOS') !== false) { |
|
| 1249 | - $this->_platform = self::PLATFORM_BEOS; |
|
| 1250 | - } elseif (stripos($this->_agent, 'win') !== false) { |
|
| 1251 | - $this->_platform = self::PLATFORM_WINDOWS; |
|
| 1252 | - } |
|
| 1253 | - |
|
| 1254 | - } |
|
| 1255 | - } |
|
| 1256 | 45 | \ No newline at end of file |
| 46 | + class Browser |
|
| 47 | + { |
|
| 48 | + private $_agent = ''; |
|
| 49 | + private $_browser_name = ''; |
|
| 50 | + private $_version = ''; |
|
| 51 | + private $_platform = ''; |
|
| 52 | + private $_os = ''; |
|
| 53 | + private $_is_aol = false; |
|
| 54 | + private $_is_mobile = false; |
|
| 55 | + private $_is_tablet = false; |
|
| 56 | + private $_is_robot = false; |
|
| 57 | + private $_is_facebook = false; |
|
| 58 | + private $_aol_version = ''; |
|
| 59 | + |
|
| 60 | + const BROWSER_UNKNOWN = 'unknown'; |
|
| 61 | + const VERSION_UNKNOWN = 'unknown'; |
|
| 62 | + |
|
| 63 | + const BROWSER_OPERA = 'Opera'; // http://www.opera.com/ |
|
| 64 | + const BROWSER_OPERA_MINI = 'Opera Mini'; // http://www.opera.com/mini/ |
|
| 65 | + const BROWSER_WEBTV = 'WebTV'; // http://www.webtv.net/pc/ |
|
| 66 | + const BROWSER_IE = 'Internet Explorer'; // http://www.microsoft.com/ie/ |
|
| 67 | + const BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // http://en.wikipedia.org/wiki/Internet_Explorer_Mobile |
|
| 68 | + const BROWSER_KONQUEROR = 'Konqueror'; // http://www.konqueror.org/ |
|
| 69 | + const BROWSER_ICAB = 'iCab'; // http://www.icab.de/ |
|
| 70 | + const BROWSER_OMNIWEB = 'OmniWeb'; // http://www.omnigroup.com/applications/omniweb/ |
|
| 71 | + const BROWSER_FIREBIRD = 'Firebird'; // http://www.ibphoenix.com/ |
|
| 72 | + const BROWSER_FIREFOX = 'Firefox'; // http://www.mozilla.com/en-US/firefox/firefox.html |
|
| 73 | + const BROWSER_ICEWEASEL = 'Iceweasel'; // http://www.geticeweasel.org/ |
|
| 74 | + const BROWSER_SHIRETOKO = 'Shiretoko'; // http://wiki.mozilla.org/Projects/shiretoko |
|
| 75 | + const BROWSER_MOZILLA = 'Mozilla'; // http://www.mozilla.com/en-US/ |
|
| 76 | + const BROWSER_AMAYA = 'Amaya'; // http://www.w3.org/Amaya/ |
|
| 77 | + const BROWSER_LYNX = 'Lynx'; // http://en.wikipedia.org/wiki/Lynx |
|
| 78 | + const BROWSER_SAFARI = 'Safari'; // http://apple.com |
|
| 79 | + const BROWSER_IPHONE = 'iPhone'; // http://apple.com |
|
| 80 | + const BROWSER_IPOD = 'iPod'; // http://apple.com |
|
| 81 | + const BROWSER_IPAD = 'iPad'; // http://apple.com |
|
| 82 | + const BROWSER_CHROME = 'Chrome'; // http://www.google.com/chrome |
|
| 83 | + const BROWSER_ANDROID = 'Android'; // http://www.android.com/ |
|
| 84 | + const BROWSER_GOOGLEBOT = 'GoogleBot'; // http://en.wikipedia.org/wiki/Googlebot |
|
| 85 | + const BROWSER_SLURP = 'Yahoo! Slurp'; // http://en.wikipedia.org/wiki/Yahoo!_Slurp |
|
| 86 | + const BROWSER_W3CVALIDATOR = 'W3C Validator'; // http://validator.w3.org/ |
|
| 87 | + const BROWSER_BLACKBERRY = 'BlackBerry'; // http://www.blackberry.com/ |
|
| 88 | + const BROWSER_ICECAT = 'IceCat'; // http://en.wikipedia.org/wiki/GNU_IceCat |
|
| 89 | + const BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // http://en.wikipedia.org/wiki/Web_Browser_for_S60 |
|
| 90 | + const BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform |
|
| 91 | + const BROWSER_MSN = 'MSN Browser'; // http://explorer.msn.com/ |
|
| 92 | + const BROWSER_MSNBOT = 'MSN Bot'; // http://search.msn.com/msnbot.htm |
|
| 93 | + const BROWSER_BINGBOT = 'Bing Bot'; // http://en.wikipedia.org/wiki/Bingbot |
|
| 94 | + |
|
| 95 | + const BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // http://browser.netscape.com/ (DEPRECATED) |
|
| 96 | + const BROWSER_GALEON = 'Galeon'; // http://galeon.sourceforge.net/ (DEPRECATED) |
|
| 97 | + const BROWSER_NETPOSITIVE = 'NetPositive'; // http://en.wikipedia.org/wiki/NetPositive (DEPRECATED) |
|
| 98 | + const BROWSER_PHOENIX = 'Phoenix'; // http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED) |
|
| 99 | + |
|
| 100 | + const PLATFORM_UNKNOWN = 'unknown'; |
|
| 101 | + const PLATFORM_WINDOWS = 'Windows'; |
|
| 102 | + const PLATFORM_WINDOWS_CE = 'Windows CE'; |
|
| 103 | + const PLATFORM_APPLE = 'Apple'; |
|
| 104 | + const PLATFORM_LINUX = 'Linux'; |
|
| 105 | + const PLATFORM_OS2 = 'OS/2'; |
|
| 106 | + const PLATFORM_BEOS = 'BeOS'; |
|
| 107 | + const PLATFORM_IPHONE = 'iPhone'; |
|
| 108 | + const PLATFORM_IPOD = 'iPod'; |
|
| 109 | + const PLATFORM_IPAD = 'iPad'; |
|
| 110 | + const PLATFORM_BLACKBERRY = 'BlackBerry'; |
|
| 111 | + const PLATFORM_NOKIA = 'Nokia'; |
|
| 112 | + const PLATFORM_FREEBSD = 'FreeBSD'; |
|
| 113 | + const PLATFORM_OPENBSD = 'OpenBSD'; |
|
| 114 | + const PLATFORM_NETBSD = 'NetBSD'; |
|
| 115 | + const PLATFORM_SUNOS = 'SunOS'; |
|
| 116 | + const PLATFORM_OPENSOLARIS = 'OpenSolaris'; |
|
| 117 | + const PLATFORM_ANDROID = 'Android'; |
|
| 118 | + |
|
| 119 | + const OPERATING_SYSTEM_UNKNOWN = 'unknown'; |
|
| 120 | + |
|
| 121 | + public function __construct($userAgent = "") |
|
| 122 | + { |
|
| 123 | + $this->reset(); |
|
| 124 | + if ($userAgent != "") { |
|
| 125 | + $this->setUserAgent($userAgent); |
|
| 126 | + } else { |
|
| 127 | + $this->determine(); |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Reset all properties |
|
| 133 | + */ |
|
| 134 | + public function reset() |
|
| 135 | + { |
|
| 136 | + $this->_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ""; |
|
| 137 | + $this->_browser_name = self::BROWSER_UNKNOWN; |
|
| 138 | + $this->_version = self::VERSION_UNKNOWN; |
|
| 139 | + $this->_platform = self::PLATFORM_UNKNOWN; |
|
| 140 | + $this->_os = self::OPERATING_SYSTEM_UNKNOWN; |
|
| 141 | + $this->_is_aol = false; |
|
| 142 | + $this->_is_mobile = false; |
|
| 143 | + $this->_is_tablet = false; |
|
| 144 | + $this->_is_robot = false; |
|
| 145 | + $this->_is_facebook = false; |
|
| 146 | + $this->_aol_version = self::VERSION_UNKNOWN; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Check to see if the specific browser is valid |
|
| 151 | + * @param string $browserName |
|
| 152 | + * @return bool True if the browser is the specified browser |
|
| 153 | + */ |
|
| 154 | + function isBrowser($browserName) |
|
| 155 | + { |
|
| 156 | + return (0 == strcasecmp($this->_browser_name, trim($browserName))); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * The name of the browser. All return types are from the class contants |
|
| 161 | + * @return string Name of the browser |
|
| 162 | + */ |
|
| 163 | + public function getBrowser() |
|
| 164 | + { |
|
| 165 | + return $this->_browser_name; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Set the name of the browser |
|
| 170 | + * @param $browser string The name of the Browser |
|
| 171 | + */ |
|
| 172 | + public function setBrowser($browser) |
|
| 173 | + { |
|
| 174 | + $this->_browser_name = $browser; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * The name of the platform. All return types are from the class contants |
|
| 179 | + * @return string Name of the browser |
|
| 180 | + */ |
|
| 181 | + public function getPlatform() |
|
| 182 | + { |
|
| 183 | + return $this->_platform; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Set the name of the platform |
|
| 188 | + * @param string $platform The name of the Platform |
|
| 189 | + */ |
|
| 190 | + public function setPlatform($platform) |
|
| 191 | + { |
|
| 192 | + $this->_platform = $platform; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * The version of the browser. |
|
| 197 | + * @return string Version of the browser (will only contain alpha-numeric characters and a period) |
|
| 198 | + */ |
|
| 199 | + public function getVersion() |
|
| 200 | + { |
|
| 201 | + return $this->_version; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Set the version of the browser |
|
| 206 | + * @param string $version The version of the Browser |
|
| 207 | + */ |
|
| 208 | + public function setVersion($version) |
|
| 209 | + { |
|
| 210 | + $this->_version = preg_replace('/[^0-9,.,a-z,A-Z-]/', '', $version); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * The version of AOL. |
|
| 215 | + * @return string Version of AOL (will only contain alpha-numeric characters and a period) |
|
| 216 | + */ |
|
| 217 | + public function getAolVersion() |
|
| 218 | + { |
|
| 219 | + return $this->_aol_version; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * Set the version of AOL |
|
| 224 | + * @param string $version The version of AOL |
|
| 225 | + */ |
|
| 226 | + public function setAolVersion($version) |
|
| 227 | + { |
|
| 228 | + $this->_aol_version = preg_replace('/[^0-9,.,a-z,A-Z]/', '', $version); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Is the browser from AOL? |
|
| 233 | + * @return boolean True if the browser is from AOL otherwise false |
|
| 234 | + */ |
|
| 235 | + public function isAol() |
|
| 236 | + { |
|
| 237 | + return $this->_is_aol; |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * Is the browser from a mobile device? |
|
| 242 | + * @return boolean True if the browser is from a mobile device otherwise false |
|
| 243 | + */ |
|
| 244 | + public function isMobile() |
|
| 245 | + { |
|
| 246 | + return $this->_is_mobile; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * Is the browser from a tablet device? |
|
| 251 | + * @return boolean True if the browser is from a tablet device otherwise false |
|
| 252 | + */ |
|
| 253 | + public function isTablet() |
|
| 254 | + { |
|
| 255 | + return $this->_is_tablet; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Is the browser from a robot (ex Slurp,GoogleBot)? |
|
| 260 | + * @return boolean True if the browser is from a robot otherwise false |
|
| 261 | + */ |
|
| 262 | + public function isRobot() |
|
| 263 | + { |
|
| 264 | + return $this->_is_robot; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + /** |
|
| 268 | + * Is the browser from facebook? |
|
| 269 | + * @return boolean True if the browser is from facebook otherwise false |
|
| 270 | + */ |
|
| 271 | + public function isFacebook() |
|
| 272 | + { |
|
| 273 | + return $this->_is_facebook; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + /** |
|
| 277 | + * Set the browser to be from AOL |
|
| 278 | + * @param $isAol |
|
| 279 | + */ |
|
| 280 | + public function setAol($isAol) |
|
| 281 | + { |
|
| 282 | + $this->_is_aol = $isAol; |
|
| 283 | + } |
|
| 284 | + |
|
| 285 | + /** |
|
| 286 | + * Set the Browser to be mobile |
|
| 287 | + * @param boolean $value is the browser a mobile browser or not |
|
| 288 | + */ |
|
| 289 | + protected function setMobile($value = true) |
|
| 290 | + { |
|
| 291 | + $this->_is_mobile = $value; |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * Set the Browser to be tablet |
|
| 296 | + * @param boolean $value is the browser a tablet browser or not |
|
| 297 | + */ |
|
| 298 | + protected function setTablet($value = true) |
|
| 299 | + { |
|
| 300 | + $this->_is_tablet = $value; |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Set the Browser to be a robot |
|
| 305 | + * @param boolean $value is the browser a robot or not |
|
| 306 | + */ |
|
| 307 | + protected function setRobot($value = true) |
|
| 308 | + { |
|
| 309 | + $this->_is_robot = $value; |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Set the Browser to be a Facebook request |
|
| 314 | + * @param boolean $value is the browser a robot or not |
|
| 315 | + */ |
|
| 316 | + protected function setFacebook($value = true) |
|
| 317 | + { |
|
| 318 | + $this->_is_facebook = $value; |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + /** |
|
| 322 | + * Get the user agent value in use to determine the browser |
|
| 323 | + * @return string The user agent from the HTTP header |
|
| 324 | + */ |
|
| 325 | + public function getUserAgent() |
|
| 326 | + { |
|
| 327 | + return $this->_agent; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * Set the user agent value (the construction will use the HTTP header value - this will overwrite it) |
|
| 332 | + * @param string $agent_string The value for the User Agent |
|
| 333 | + */ |
|
| 334 | + public function setUserAgent($agent_string) |
|
| 335 | + { |
|
| 336 | + $this->reset(); |
|
| 337 | + $this->_agent = $agent_string; |
|
| 338 | + $this->determine(); |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * Used to determine if the browser is actually "chromeframe" |
|
| 343 | + * @since 1.7 |
|
| 344 | + * @return boolean True if the browser is using chromeframe |
|
| 345 | + */ |
|
| 346 | + public function isChromeFrame() |
|
| 347 | + { |
|
| 348 | + return (strpos($this->_agent, "chromeframe") !== false); |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + /** |
|
| 352 | + * Returns a formatted string with a summary of the details of the browser. |
|
| 353 | + * @return string formatted string with a summary of the browser |
|
| 354 | + */ |
|
| 355 | + public function __toString() |
|
| 356 | + { |
|
| 357 | + return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
| 358 | + "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
| 359 | + "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
| 360 | + "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + /** |
|
| 364 | + * Protected routine to calculate and determine what the browser is in use (including platform) |
|
| 365 | + */ |
|
| 366 | + protected function determine() |
|
| 367 | + { |
|
| 368 | + $this->checkPlatform(); |
|
| 369 | + $this->checkBrowsers(); |
|
| 370 | + $this->checkForAol(); |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + /** |
|
| 374 | + * Protected routine to determine the browser type |
|
| 375 | + * @return boolean True if the browser was detected otherwise false |
|
| 376 | + */ |
|
| 377 | + protected function checkBrowsers() |
|
| 378 | + { |
|
| 379 | + return ( |
|
| 380 | + // well-known, well-used |
|
| 381 | + // Special Notes: |
|
| 382 | + // (1) Opera must be checked before FireFox due to the odd |
|
| 383 | + // user agents used in some older versions of Opera |
|
| 384 | + // (2) WebTV is strapped onto Internet Explorer so we must |
|
| 385 | + // check for WebTV before IE |
|
| 386 | + // (3) (deprecated) Galeon is based on Firefox and needs to be |
|
| 387 | + // tested before Firefox is tested |
|
| 388 | + // (4) OmniWeb is based on Safari so OmniWeb check must occur |
|
| 389 | + // before Safari |
|
| 390 | + // (5) Netscape 9+ is based on Firefox so Netscape checks |
|
| 391 | + // before FireFox are necessary |
|
| 392 | + $this->checkBrowserWebTv() || |
|
| 393 | + $this->checkBrowserInternetExplorer() || |
|
| 394 | + $this->checkBrowserOpera() || |
|
| 395 | + $this->checkBrowserGaleon() || |
|
| 396 | + $this->checkBrowserNetscapeNavigator9Plus() || |
|
| 397 | + $this->checkBrowserFirefox() || |
|
| 398 | + $this->checkBrowserChrome() || |
|
| 399 | + $this->checkBrowserOmniWeb() || |
|
| 400 | + |
|
| 401 | + // common mobile |
|
| 402 | + $this->checkBrowserAndroid() || |
|
| 403 | + $this->checkBrowseriPad() || |
|
| 404 | + $this->checkBrowseriPod() || |
|
| 405 | + $this->checkBrowseriPhone() || |
|
| 406 | + $this->checkBrowserBlackBerry() || |
|
| 407 | + $this->checkBrowserNokia() || |
|
| 408 | + |
|
| 409 | + // common bots |
|
| 410 | + $this->checkBrowserGoogleBot() || |
|
| 411 | + $this->checkBrowserMSNBot() || |
|
| 412 | + $this->checkBrowserBingBot() || |
|
| 413 | + $this->checkBrowserSlurp() || |
|
| 414 | + |
|
| 415 | + // check for facebook external hit when loading URL |
|
| 416 | + $this->checkFacebookExternalHit() || |
|
| 417 | + |
|
| 418 | + // WebKit base check (post mobile and others) |
|
| 419 | + $this->checkBrowserSafari() || |
|
| 420 | + |
|
| 421 | + // everyone else |
|
| 422 | + $this->checkBrowserNetPositive() || |
|
| 423 | + $this->checkBrowserFirebird() || |
|
| 424 | + $this->checkBrowserKonqueror() || |
|
| 425 | + $this->checkBrowserIcab() || |
|
| 426 | + $this->checkBrowserPhoenix() || |
|
| 427 | + $this->checkBrowserAmaya() || |
|
| 428 | + $this->checkBrowserLynx() || |
|
| 429 | + $this->checkBrowserShiretoko() || |
|
| 430 | + $this->checkBrowserIceCat() || |
|
| 431 | + $this->checkBrowserIceweasel() || |
|
| 432 | + $this->checkBrowserW3CValidator() || |
|
| 433 | + $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */ |
|
| 434 | + ); |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + /** |
|
| 438 | + * Determine if the user is using a BlackBerry (last updated 1.7) |
|
| 439 | + * @return boolean True if the browser is the BlackBerry browser otherwise false |
|
| 440 | + */ |
|
| 441 | + protected function checkBrowserBlackBerry() |
|
| 442 | + { |
|
| 443 | + if (stripos($this->_agent, 'blackberry') !== false) { |
|
| 444 | + $aresult = explode("/", stristr($this->_agent, "BlackBerry")); |
|
| 445 | + if (isset($aresult[1])) { |
|
| 446 | + $aversion = explode(' ', $aresult[1]); |
|
| 447 | + $this->setVersion($aversion[0]); |
|
| 448 | + $this->_browser_name = self::BROWSER_BLACKBERRY; |
|
| 449 | + $this->setMobile(true); |
|
| 450 | + return true; |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | + return false; |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * Determine if the user is using an AOL User Agent (last updated 1.7) |
|
| 458 | + * @return boolean True if the browser is from AOL otherwise false |
|
| 459 | + */ |
|
| 460 | + protected function checkForAol() |
|
| 461 | + { |
|
| 462 | + $this->setAol(false); |
|
| 463 | + $this->setAolVersion(self::VERSION_UNKNOWN); |
|
| 464 | + |
|
| 465 | + if (stripos($this->_agent, 'aol') !== false) { |
|
| 466 | + $aversion = explode(' ', stristr($this->_agent, 'AOL')); |
|
| 467 | + if (isset($aversion[1])) { |
|
| 468 | + $this->setAol(true); |
|
| 469 | + $this->setAolVersion(preg_replace('/[^0-9\.a-z]/i', '', $aversion[1])); |
|
| 470 | + return true; |
|
| 471 | + } |
|
| 472 | + } |
|
| 473 | + return false; |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * Determine if the browser is the GoogleBot or not (last updated 1.7) |
|
| 478 | + * @return boolean True if the browser is the GoogletBot otherwise false |
|
| 479 | + */ |
|
| 480 | + protected function checkBrowserGoogleBot() |
|
| 481 | + { |
|
| 482 | + if (stripos($this->_agent, 'googlebot') !== false) { |
|
| 483 | + $aresult = explode('/', stristr($this->_agent, 'googlebot')); |
|
| 484 | + if (isset($aresult[1])) { |
|
| 485 | + $aversion = explode(' ', $aresult[1]); |
|
| 486 | + $this->setVersion(str_replace(';', '', $aversion[0])); |
|
| 487 | + $this->_browser_name = self::BROWSER_GOOGLEBOT; |
|
| 488 | + $this->setRobot(true); |
|
| 489 | + return true; |
|
| 490 | + } |
|
| 491 | + } |
|
| 492 | + return false; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * Determine if the browser is the MSNBot or not (last updated 1.9) |
|
| 497 | + * @return boolean True if the browser is the MSNBot otherwise false |
|
| 498 | + */ |
|
| 499 | + protected function checkBrowserMSNBot() |
|
| 500 | + { |
|
| 501 | + if (stripos($this->_agent, "msnbot") !== false) { |
|
| 502 | + $aresult = explode("/", stristr($this->_agent, "msnbot")); |
|
| 503 | + if (isset($aresult[1])) { |
|
| 504 | + $aversion = explode(" ", $aresult[1]); |
|
| 505 | + $this->setVersion(str_replace(";", "", $aversion[0])); |
|
| 506 | + $this->_browser_name = self::BROWSER_MSNBOT; |
|
| 507 | + $this->setRobot(true); |
|
| 508 | + return true; |
|
| 509 | + } |
|
| 510 | + } |
|
| 511 | + return false; |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + /** |
|
| 515 | + * Determine if the browser is the BingBot or not (last updated 1.9) |
|
| 516 | + * @return boolean True if the browser is the BingBot otherwise false |
|
| 517 | + */ |
|
| 518 | + protected function checkBrowserBingBot() |
|
| 519 | + { |
|
| 520 | + if (stripos($this->_agent, "bingbot") !== false) { |
|
| 521 | + $aresult = explode("/", stristr($this->_agent, "bingbot")); |
|
| 522 | + if (isset($aresult[1])) { |
|
| 523 | + $aversion = explode(" ", $aresult[1]); |
|
| 524 | + $this->setVersion(str_replace(";", "", $aversion[0])); |
|
| 525 | + $this->_browser_name = self::BROWSER_BINGBOT; |
|
| 526 | + $this->setRobot(true); |
|
| 527 | + return true; |
|
| 528 | + } |
|
| 529 | + } |
|
| 530 | + return false; |
|
| 531 | + } |
|
| 532 | + |
|
| 533 | + /** |
|
| 534 | + * Determine if the browser is the W3C Validator or not (last updated 1.7) |
|
| 535 | + * @return boolean True if the browser is the W3C Validator otherwise false |
|
| 536 | + */ |
|
| 537 | + protected function checkBrowserW3CValidator() |
|
| 538 | + { |
|
| 539 | + if (stripos($this->_agent, 'W3C-checklink') !== false) { |
|
| 540 | + $aresult = explode('/', stristr($this->_agent, 'W3C-checklink')); |
|
| 541 | + if (isset($aresult[1])) { |
|
| 542 | + $aversion = explode(' ', $aresult[1]); |
|
| 543 | + $this->setVersion($aversion[0]); |
|
| 544 | + $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 545 | + return true; |
|
| 546 | + } |
|
| 547 | + } else if (stripos($this->_agent, 'W3C_Validator') !== false) { |
|
| 548 | + // Some of the Validator versions do not delineate w/ a slash - add it back in |
|
| 549 | + $ua = str_replace("W3C_Validator ", "W3C_Validator/", $this->_agent); |
|
| 550 | + $aresult = explode('/', stristr($ua, 'W3C_Validator')); |
|
| 551 | + if (isset($aresult[1])) { |
|
| 552 | + $aversion = explode(' ', $aresult[1]); |
|
| 553 | + $this->setVersion($aversion[0]); |
|
| 554 | + $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 555 | + return true; |
|
| 556 | + } |
|
| 557 | + } else if (stripos($this->_agent, 'W3C-mobileOK') !== false) { |
|
| 558 | + $this->_browser_name = self::BROWSER_W3CVALIDATOR; |
|
| 559 | + $this->setMobile(true); |
|
| 560 | + return true; |
|
| 561 | + } |
|
| 562 | + return false; |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + /** |
|
| 566 | + * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7) |
|
| 567 | + * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false |
|
| 568 | + */ |
|
| 569 | + protected function checkBrowserSlurp() |
|
| 570 | + { |
|
| 571 | + if (stripos($this->_agent, 'slurp') !== false) { |
|
| 572 | + $aresult = explode('/', stristr($this->_agent, 'Slurp')); |
|
| 573 | + if (isset($aresult[1])) { |
|
| 574 | + $aversion = explode(' ', $aresult[1]); |
|
| 575 | + $this->setVersion($aversion[0]); |
|
| 576 | + $this->_browser_name = self::BROWSER_SLURP; |
|
| 577 | + $this->setRobot(true); |
|
| 578 | + $this->setMobile(false); |
|
| 579 | + return true; |
|
| 580 | + } |
|
| 581 | + } |
|
| 582 | + return false; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + /** |
|
| 586 | + * Determine if the browser is Internet Explorer or not (last updated 1.7) |
|
| 587 | + * @return boolean True if the browser is Internet Explorer otherwise false |
|
| 588 | + */ |
|
| 589 | + protected function checkBrowserInternetExplorer() |
|
| 590 | + { |
|
| 591 | + // Test for IE11 |
|
| 592 | + if (stripos($this->_agent, 'Trident/7.0; rv:11.0') !== false) { |
|
| 593 | + $this->setBrowser(self::BROWSER_IE); |
|
| 594 | + $this->setVersion('11.0'); |
|
| 595 | + return true; |
|
| 596 | + } // Test for v1 - v1.5 IE |
|
| 597 | + else if (stripos($this->_agent, 'microsoft internet explorer') !== false) { |
|
| 598 | + $this->setBrowser(self::BROWSER_IE); |
|
| 599 | + $this->setVersion('1.0'); |
|
| 600 | + $aresult = stristr($this->_agent, '/'); |
|
| 601 | + if (preg_match('/308|425|426|474|0b1/i', $aresult)) { |
|
| 602 | + $this->setVersion('1.5'); |
|
| 603 | + } |
|
| 604 | + return true; |
|
| 605 | + } // Test for versions > 1.5 |
|
| 606 | + else if (stripos($this->_agent, 'msie') !== false && stripos($this->_agent, 'opera') === false) { |
|
| 607 | + // See if the browser is the odd MSN Explorer |
|
| 608 | + if (stripos($this->_agent, 'msnb') !== false) { |
|
| 609 | + $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'MSN')); |
|
| 610 | + if (isset($aresult[1])) { |
|
| 611 | + $this->setBrowser(self::BROWSER_MSN); |
|
| 612 | + $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
|
| 613 | + return true; |
|
| 614 | + } |
|
| 615 | + } |
|
| 616 | + $aresult = explode(' ', stristr(str_replace(';', '; ', $this->_agent), 'msie')); |
|
| 617 | + if (isset($aresult[1])) { |
|
| 618 | + $this->setBrowser(self::BROWSER_IE); |
|
| 619 | + $this->setVersion(str_replace(array('(', ')', ';'), '', $aresult[1])); |
|
| 620 | + if (stripos($this->_agent, 'IEMobile') !== false) { |
|
| 621 | + $this->setBrowser(self::BROWSER_POCKET_IE); |
|
| 622 | + $this->setMobile(true); |
|
| 623 | + } |
|
| 624 | + return true; |
|
| 625 | + } |
|
| 626 | + } // Test for versions > IE 10 |
|
| 627 | + else if (stripos($this->_agent, 'trident') !== false) { |
|
| 628 | + $this->setBrowser(self::BROWSER_IE); |
|
| 629 | + $result = explode('rv:', $this->_agent); |
|
| 630 | + if (isset($result[1])) { |
|
| 631 | + $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1])); |
|
| 632 | + $this->_agent = str_replace(array("Mozilla", "Gecko"), "MSIE", $this->_agent); |
|
| 633 | + } |
|
| 634 | + } // Test for Pocket IE |
|
| 635 | + else if (stripos($this->_agent, 'mspie') !== false || stripos($this->_agent, 'pocket') !== false) { |
|
| 636 | + $aresult = explode(' ', stristr($this->_agent, 'mspie')); |
|
| 637 | + if (isset($aresult[1])) { |
|
| 638 | + $this->setPlatform(self::PLATFORM_WINDOWS_CE); |
|
| 639 | + $this->setBrowser(self::BROWSER_POCKET_IE); |
|
| 640 | + $this->setMobile(true); |
|
| 641 | + |
|
| 642 | + if (stripos($this->_agent, 'mspie') !== false) { |
|
| 643 | + $this->setVersion($aresult[1]); |
|
| 644 | + } else { |
|
| 645 | + $aversion = explode('/', $this->_agent); |
|
| 646 | + if (isset($aversion[1])) { |
|
| 647 | + $this->setVersion($aversion[1]); |
|
| 648 | + } |
|
| 649 | + } |
|
| 650 | + return true; |
|
| 651 | + } |
|
| 652 | + } |
|
| 653 | + return false; |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * Determine if the browser is Opera or not (last updated 1.7) |
|
| 658 | + * @return boolean True if the browser is Opera otherwise false |
|
| 659 | + */ |
|
| 660 | + protected function checkBrowserOpera() |
|
| 661 | + { |
|
| 662 | + if (stripos($this->_agent, 'opera mini') !== false) { |
|
| 663 | + $resultant = stristr($this->_agent, 'opera mini'); |
|
| 664 | + if (preg_match('/\//', $resultant)) { |
|
| 665 | + $aresult = explode('/', $resultant); |
|
| 666 | + if (isset($aresult[1])) { |
|
| 667 | + $aversion = explode(' ', $aresult[1]); |
|
| 668 | + $this->setVersion($aversion[0]); |
|
| 669 | + } |
|
| 670 | + } else { |
|
| 671 | + $aversion = explode(' ', stristr($resultant, 'opera mini')); |
|
| 672 | + if (isset($aversion[1])) { |
|
| 673 | + $this->setVersion($aversion[1]); |
|
| 674 | + } |
|
| 675 | + } |
|
| 676 | + $this->_browser_name = self::BROWSER_OPERA_MINI; |
|
| 677 | + $this->setMobile(true); |
|
| 678 | + return true; |
|
| 679 | + } else if (stripos($this->_agent, 'opera') !== false) { |
|
| 680 | + $resultant = stristr($this->_agent, 'opera'); |
|
| 681 | + if (preg_match('/Version\/(1*.*)$/', $resultant, $matches)) { |
|
| 682 | + $this->setVersion($matches[1]); |
|
| 683 | + } else if (preg_match('/\//', $resultant)) { |
|
| 684 | + $aresult = explode('/', str_replace("(", " ", $resultant)); |
|
| 685 | + if (isset($aresult[1])) { |
|
| 686 | + $aversion = explode(' ', $aresult[1]); |
|
| 687 | + $this->setVersion($aversion[0]); |
|
| 688 | + } |
|
| 689 | + } else { |
|
| 690 | + $aversion = explode(' ', stristr($resultant, 'opera')); |
|
| 691 | + $this->setVersion(isset($aversion[1]) ? $aversion[1] : ""); |
|
| 692 | + } |
|
| 693 | + if (stripos($this->_agent, 'Opera Mobi') !== false) { |
|
| 694 | + $this->setMobile(true); |
|
| 695 | + } |
|
| 696 | + $this->_browser_name = self::BROWSER_OPERA; |
|
| 697 | + return true; |
|
| 698 | + } else if (stripos($this->_agent, 'OPR') !== false) { |
|
| 699 | + $resultant = stristr($this->_agent, 'OPR'); |
|
| 700 | + if (preg_match('/\//', $resultant)) { |
|
| 701 | + $aresult = explode('/', str_replace("(", " ", $resultant)); |
|
| 702 | + if (isset($aresult[1])) { |
|
| 703 | + $aversion = explode(' ', $aresult[1]); |
|
| 704 | + $this->setVersion($aversion[0]); |
|
| 705 | + } |
|
| 706 | + } |
|
| 707 | + if (stripos($this->_agent, 'Mobile') !== false) { |
|
| 708 | + $this->setMobile(true); |
|
| 709 | + } |
|
| 710 | + $this->_browser_name = self::BROWSER_OPERA; |
|
| 711 | + return true; |
|
| 712 | + } |
|
| 713 | + return false; |
|
| 714 | + } |
|
| 715 | + |
|
| 716 | + /** |
|
| 717 | + * Determine if the browser is Chrome or not (last updated 1.7) |
|
| 718 | + * @return boolean True if the browser is Chrome otherwise false |
|
| 719 | + */ |
|
| 720 | + protected function checkBrowserChrome() |
|
| 721 | + { |
|
| 722 | + if (stripos($this->_agent, 'Chrome') !== false) { |
|
| 723 | + $aresult = explode('/', stristr($this->_agent, 'Chrome')); |
|
| 724 | + if (isset($aresult[1])) { |
|
| 725 | + $aversion = explode(' ', $aresult[1]); |
|
| 726 | + $this->setVersion($aversion[0]); |
|
| 727 | + $this->setBrowser(self::BROWSER_CHROME); |
|
| 728 | + //Chrome on Android |
|
| 729 | + if (stripos($this->_agent, 'Android') !== false) { |
|
| 730 | + if (stripos($this->_agent, 'Mobile') !== false) { |
|
| 731 | + $this->setMobile(true); |
|
| 732 | + } else { |
|
| 733 | + $this->setTablet(true); |
|
| 734 | + } |
|
| 735 | + } |
|
| 736 | + return true; |
|
| 737 | + } |
|
| 738 | + } |
|
| 739 | + return false; |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + |
|
| 743 | + /** |
|
| 744 | + * Determine if the browser is WebTv or not (last updated 1.7) |
|
| 745 | + * @return boolean True if the browser is WebTv otherwise false |
|
| 746 | + */ |
|
| 747 | + protected function checkBrowserWebTv() |
|
| 748 | + { |
|
| 749 | + if (stripos($this->_agent, 'webtv') !== false) { |
|
| 750 | + $aresult = explode('/', stristr($this->_agent, 'webtv')); |
|
| 751 | + if (isset($aresult[1])) { |
|
| 752 | + $aversion = explode(' ', $aresult[1]); |
|
| 753 | + $this->setVersion($aversion[0]); |
|
| 754 | + $this->setBrowser(self::BROWSER_WEBTV); |
|
| 755 | + return true; |
|
| 756 | + } |
|
| 757 | + } |
|
| 758 | + return false; |
|
| 759 | + } |
|
| 760 | + |
|
| 761 | + /** |
|
| 762 | + * Determine if the browser is NetPositive or not (last updated 1.7) |
|
| 763 | + * @return boolean True if the browser is NetPositive otherwise false |
|
| 764 | + */ |
|
| 765 | + protected function checkBrowserNetPositive() |
|
| 766 | + { |
|
| 767 | + if (stripos($this->_agent, 'NetPositive') !== false) { |
|
| 768 | + $aresult = explode('/', stristr($this->_agent, 'NetPositive')); |
|
| 769 | + if (isset($aresult[1])) { |
|
| 770 | + $aversion = explode(' ', $aresult[1]); |
|
| 771 | + $this->setVersion(str_replace(array('(', ')', ';'), '', $aversion[0])); |
|
| 772 | + $this->setBrowser(self::BROWSER_NETPOSITIVE); |
|
| 773 | + return true; |
|
| 774 | + } |
|
| 775 | + } |
|
| 776 | + return false; |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + /** |
|
| 780 | + * Determine if the browser is Galeon or not (last updated 1.7) |
|
| 781 | + * @return boolean True if the browser is Galeon otherwise false |
|
| 782 | + */ |
|
| 783 | + protected function checkBrowserGaleon() |
|
| 784 | + { |
|
| 785 | + if (stripos($this->_agent, 'galeon') !== false) { |
|
| 786 | + $aresult = explode(' ', stristr($this->_agent, 'galeon')); |
|
| 787 | + $aversion = explode('/', $aresult[0]); |
|
| 788 | + if (isset($aversion[1])) { |
|
| 789 | + $this->setVersion($aversion[1]); |
|
| 790 | + $this->setBrowser(self::BROWSER_GALEON); |
|
| 791 | + return true; |
|
| 792 | + } |
|
| 793 | + } |
|
| 794 | + return false; |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + /** |
|
| 798 | + * Determine if the browser is Konqueror or not (last updated 1.7) |
|
| 799 | + * @return boolean True if the browser is Konqueror otherwise false |
|
| 800 | + */ |
|
| 801 | + protected function checkBrowserKonqueror() |
|
| 802 | + { |
|
| 803 | + if (stripos($this->_agent, 'Konqueror') !== false) { |
|
| 804 | + $aresult = explode(' ', stristr($this->_agent, 'Konqueror')); |
|
| 805 | + $aversion = explode('/', $aresult[0]); |
|
| 806 | + if (isset($aversion[1])) { |
|
| 807 | + $this->setVersion($aversion[1]); |
|
| 808 | + $this->setBrowser(self::BROWSER_KONQUEROR); |
|
| 809 | + return true; |
|
| 810 | + } |
|
| 811 | + } |
|
| 812 | + return false; |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + /** |
|
| 816 | + * Determine if the browser is iCab or not (last updated 1.7) |
|
| 817 | + * @return boolean True if the browser is iCab otherwise false |
|
| 818 | + */ |
|
| 819 | + protected function checkBrowserIcab() |
|
| 820 | + { |
|
| 821 | + if (stripos($this->_agent, 'icab') !== false) { |
|
| 822 | + $aversion = explode(' ', stristr(str_replace('/', ' ', $this->_agent), 'icab')); |
|
| 823 | + if (isset($aversion[1])) { |
|
| 824 | + $this->setVersion($aversion[1]); |
|
| 825 | + $this->setBrowser(self::BROWSER_ICAB); |
|
| 826 | + return true; |
|
| 827 | + } |
|
| 828 | + } |
|
| 829 | + return false; |
|
| 830 | + } |
|
| 831 | + |
|
| 832 | + /** |
|
| 833 | + * Determine if the browser is OmniWeb or not (last updated 1.7) |
|
| 834 | + * @return boolean True if the browser is OmniWeb otherwise false |
|
| 835 | + */ |
|
| 836 | + protected function checkBrowserOmniWeb() |
|
| 837 | + { |
|
| 838 | + if (stripos($this->_agent, 'omniweb') !== false) { |
|
| 839 | + $aresult = explode('/', stristr($this->_agent, 'omniweb')); |
|
| 840 | + $aversion = explode(' ', isset($aresult[1]) ? $aresult[1] : ""); |
|
| 841 | + $this->setVersion($aversion[0]); |
|
| 842 | + $this->setBrowser(self::BROWSER_OMNIWEB); |
|
| 843 | + return true; |
|
| 844 | + } |
|
| 845 | + return false; |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + /** |
|
| 849 | + * Determine if the browser is Phoenix or not (last updated 1.7) |
|
| 850 | + * @return boolean True if the browser is Phoenix otherwise false |
|
| 851 | + */ |
|
| 852 | + protected function checkBrowserPhoenix() |
|
| 853 | + { |
|
| 854 | + if (stripos($this->_agent, 'Phoenix') !== false) { |
|
| 855 | + $aversion = explode('/', stristr($this->_agent, 'Phoenix')); |
|
| 856 | + if (isset($aversion[1])) { |
|
| 857 | + $this->setVersion($aversion[1]); |
|
| 858 | + $this->setBrowser(self::BROWSER_PHOENIX); |
|
| 859 | + return true; |
|
| 860 | + } |
|
| 861 | + } |
|
| 862 | + return false; |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + /** |
|
| 866 | + * Determine if the browser is Firebird or not (last updated 1.7) |
|
| 867 | + * @return boolean True if the browser is Firebird otherwise false |
|
| 868 | + */ |
|
| 869 | + protected function checkBrowserFirebird() |
|
| 870 | + { |
|
| 871 | + if (stripos($this->_agent, 'Firebird') !== false) { |
|
| 872 | + $aversion = explode('/', stristr($this->_agent, 'Firebird')); |
|
| 873 | + if (isset($aversion[1])) { |
|
| 874 | + $this->setVersion($aversion[1]); |
|
| 875 | + $this->setBrowser(self::BROWSER_FIREBIRD); |
|
| 876 | + return true; |
|
| 877 | + } |
|
| 878 | + } |
|
| 879 | + return false; |
|
| 880 | + } |
|
| 881 | + |
|
| 882 | + /** |
|
| 883 | + * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7) |
|
| 884 | + * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008) |
|
| 885 | + * @return boolean True if the browser is Netscape Navigator 9+ otherwise false |
|
| 886 | + */ |
|
| 887 | + protected function checkBrowserNetscapeNavigator9Plus() |
|
| 888 | + { |
|
| 889 | + if (stripos($this->_agent, 'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i', $this->_agent, $matches)) { |
|
| 890 | + $this->setVersion($matches[1]); |
|
| 891 | + $this->setBrowser(self::BROWSER_NETSCAPE_NAVIGATOR); |
|
| 892 | + return true; |
|
| 893 | + } else if (stripos($this->_agent, 'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i', $this->_agent, $matches)) { |
|
| 894 | + $this->setVersion($matches[1]); |
|
| 895 | + $this->setBrowser(self::BROWSER_NETSCAPE_NAVIGATOR); |
|
| 896 | + return true; |
|
| 897 | + } |
|
| 898 | + return false; |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + /** |
|
| 902 | + * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7) |
|
| 903 | + * @return boolean True if the browser is Shiretoko otherwise false |
|
| 904 | + */ |
|
| 905 | + protected function checkBrowserShiretoko() |
|
| 906 | + { |
|
| 907 | + if (stripos($this->_agent, 'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i', $this->_agent, $matches)) { |
|
| 908 | + $this->setVersion($matches[1]); |
|
| 909 | + $this->setBrowser(self::BROWSER_SHIRETOKO); |
|
| 910 | + return true; |
|
| 911 | + } |
|
| 912 | + return false; |
|
| 913 | + } |
|
| 914 | + |
|
| 915 | + /** |
|
| 916 | + * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7) |
|
| 917 | + * @return boolean True if the browser is Ice Cat otherwise false |
|
| 918 | + */ |
|
| 919 | + protected function checkBrowserIceCat() |
|
| 920 | + { |
|
| 921 | + if (stripos($this->_agent, 'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i', $this->_agent, $matches)) { |
|
| 922 | + $this->setVersion($matches[1]); |
|
| 923 | + $this->setBrowser(self::BROWSER_ICECAT); |
|
| 924 | + return true; |
|
| 925 | + } |
|
| 926 | + return false; |
|
| 927 | + } |
|
| 928 | + |
|
| 929 | + /** |
|
| 930 | + * Determine if the browser is Nokia or not (last updated 1.7) |
|
| 931 | + * @return boolean True if the browser is Nokia otherwise false |
|
| 932 | + */ |
|
| 933 | + protected function checkBrowserNokia() |
|
| 934 | + { |
|
| 935 | + if (preg_match("/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches)) { |
|
| 936 | + $this->setVersion($matches[2]); |
|
| 937 | + if (stripos($this->_agent, 'Series60') !== false || strpos($this->_agent, 'S60') !== false) { |
|
| 938 | + $this->setBrowser(self::BROWSER_NOKIA_S60); |
|
| 939 | + } else { |
|
| 940 | + $this->setBrowser(self::BROWSER_NOKIA); |
|
| 941 | + } |
|
| 942 | + $this->setMobile(true); |
|
| 943 | + return true; |
|
| 944 | + } |
|
| 945 | + return false; |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + /** |
|
| 949 | + * Determine if the browser is Firefox or not (last updated 1.7) |
|
| 950 | + * @return boolean True if the browser is Firefox otherwise false |
|
| 951 | + */ |
|
| 952 | + protected function checkBrowserFirefox() |
|
| 953 | + { |
|
| 954 | + if (stripos($this->_agent, 'safari') === false) { |
|
| 955 | + if (preg_match("/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches)) { |
|
| 956 | + $this->setVersion($matches[1]); |
|
| 957 | + $this->setBrowser(self::BROWSER_FIREFOX); |
|
| 958 | + //Firefox on Android |
|
| 959 | + if (stripos($this->_agent, 'Android') !== false) { |
|
| 960 | + if (stripos($this->_agent, 'Mobile') !== false) { |
|
| 961 | + $this->setMobile(true); |
|
| 962 | + } else { |
|
| 963 | + $this->setTablet(true); |
|
| 964 | + } |
|
| 965 | + } |
|
| 966 | + return true; |
|
| 967 | + } else if (preg_match("/Firefox$/i", $this->_agent, $matches)) { |
|
| 968 | + $this->setVersion(""); |
|
| 969 | + $this->setBrowser(self::BROWSER_FIREFOX); |
|
| 970 | + return true; |
|
| 971 | + } |
|
| 972 | + } |
|
| 973 | + return false; |
|
| 974 | + } |
|
| 975 | + |
|
| 976 | + /** |
|
| 977 | + * Determine if the browser is Firefox or not (last updated 1.7) |
|
| 978 | + * @return boolean True if the browser is Firefox otherwise false |
|
| 979 | + */ |
|
| 980 | + protected function checkBrowserIceweasel() |
|
| 981 | + { |
|
| 982 | + if (stripos($this->_agent, 'Iceweasel') !== false) { |
|
| 983 | + $aresult = explode('/', stristr($this->_agent, 'Iceweasel')); |
|
| 984 | + if (isset($aresult[1])) { |
|
| 985 | + $aversion = explode(' ', $aresult[1]); |
|
| 986 | + $this->setVersion($aversion[0]); |
|
| 987 | + $this->setBrowser(self::BROWSER_ICEWEASEL); |
|
| 988 | + return true; |
|
| 989 | + } |
|
| 990 | + } |
|
| 991 | + return false; |
|
| 992 | + } |
|
| 993 | + |
|
| 994 | + /** |
|
| 995 | + * Determine if the browser is Mozilla or not (last updated 1.7) |
|
| 996 | + * @return boolean True if the browser is Mozilla otherwise false |
|
| 997 | + */ |
|
| 998 | + protected function checkBrowserMozilla() |
|
| 999 | + { |
|
| 1000 | + if (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) { |
|
| 1001 | + $aversion = explode(' ', stristr($this->_agent, 'rv:')); |
|
| 1002 | + preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion); |
|
| 1003 | + $this->setVersion(str_replace('rv:', '', $aversion[0])); |
|
| 1004 | + $this->setBrowser(self::BROWSER_MOZILLA); |
|
| 1005 | + return true; |
|
| 1006 | + } else if (stripos($this->_agent, 'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i', $this->_agent) && stripos($this->_agent, 'netscape') === false) { |
|
| 1007 | + $aversion = explode('', stristr($this->_agent, 'rv:')); |
|
| 1008 | + $this->setVersion(str_replace('rv:', '', $aversion[0])); |
|
| 1009 | + $this->setBrowser(self::BROWSER_MOZILLA); |
|
| 1010 | + return true; |
|
| 1011 | + } else if (stripos($this->_agent, 'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i', $this->_agent, $matches) && stripos($this->_agent, 'netscape') === false) { |
|
| 1012 | + $this->setVersion($matches[1]); |
|
| 1013 | + $this->setBrowser(self::BROWSER_MOZILLA); |
|
| 1014 | + return true; |
|
| 1015 | + } |
|
| 1016 | + return false; |
|
| 1017 | + } |
|
| 1018 | + |
|
| 1019 | + /** |
|
| 1020 | + * Determine if the browser is Lynx or not (last updated 1.7) |
|
| 1021 | + * @return boolean True if the browser is Lynx otherwise false |
|
| 1022 | + */ |
|
| 1023 | + protected function checkBrowserLynx() |
|
| 1024 | + { |
|
| 1025 | + if (stripos($this->_agent, 'lynx') !== false) { |
|
| 1026 | + $aresult = explode('/', stristr($this->_agent, 'Lynx')); |
|
| 1027 | + $aversion = explode(' ', (isset($aresult[1]) ? $aresult[1] : "")); |
|
| 1028 | + $this->setVersion($aversion[0]); |
|
| 1029 | + $this->setBrowser(self::BROWSER_LYNX); |
|
| 1030 | + return true; |
|
| 1031 | + } |
|
| 1032 | + return false; |
|
| 1033 | + } |
|
| 1034 | + |
|
| 1035 | + /** |
|
| 1036 | + * Determine if the browser is Amaya or not (last updated 1.7) |
|
| 1037 | + * @return boolean True if the browser is Amaya otherwise false |
|
| 1038 | + */ |
|
| 1039 | + protected function checkBrowserAmaya() |
|
| 1040 | + { |
|
| 1041 | + if (stripos($this->_agent, 'amaya') !== false) { |
|
| 1042 | + $aresult = explode('/', stristr($this->_agent, 'Amaya')); |
|
| 1043 | + if (isset($aresult[1])) { |
|
| 1044 | + $aversion = explode(' ', $aresult[1]); |
|
| 1045 | + $this->setVersion($aversion[0]); |
|
| 1046 | + $this->setBrowser(self::BROWSER_AMAYA); |
|
| 1047 | + return true; |
|
| 1048 | + } |
|
| 1049 | + } |
|
| 1050 | + return false; |
|
| 1051 | + } |
|
| 1052 | + |
|
| 1053 | + /** |
|
| 1054 | + * Determine if the browser is Safari or not (last updated 1.7) |
|
| 1055 | + * @return boolean True if the browser is Safari otherwise false |
|
| 1056 | + */ |
|
| 1057 | + protected function checkBrowserSafari() |
|
| 1058 | + { |
|
| 1059 | + if (stripos($this->_agent, 'Safari') !== false |
|
| 1060 | + && stripos($this->_agent, 'iPhone') === false |
|
| 1061 | + && stripos($this->_agent, 'iPod') === false |
|
| 1062 | + ) { |
|
| 1063 | + |
|
| 1064 | + $aresult = explode('/', stristr($this->_agent, 'Version')); |
|
| 1065 | + if (isset($aresult[1])) { |
|
| 1066 | + $aversion = explode(' ', $aresult[1]); |
|
| 1067 | + $this->setVersion($aversion[0]); |
|
| 1068 | + } else { |
|
| 1069 | + $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1070 | + } |
|
| 1071 | + $this->setBrowser(self::BROWSER_SAFARI); |
|
| 1072 | + return true; |
|
| 1073 | + } |
|
| 1074 | + return false; |
|
| 1075 | + } |
|
| 1076 | + |
|
| 1077 | + /** |
|
| 1078 | + * Detect if URL is loaded from FacebookExternalHit |
|
| 1079 | + * @return boolean True if it detects FacebookExternalHit otherwise false |
|
| 1080 | + */ |
|
| 1081 | + protected function checkFacebookExternalHit() |
|
| 1082 | + { |
|
| 1083 | + if (stristr($this->_agent, 'FacebookExternalHit')) { |
|
| 1084 | + $this->setRobot(true); |
|
| 1085 | + $this->setFacebook(true); |
|
| 1086 | + return true; |
|
| 1087 | + } |
|
| 1088 | + return false; |
|
| 1089 | + } |
|
| 1090 | + |
|
| 1091 | + /** |
|
| 1092 | + * Detect if URL is being loaded from internal Facebook browser |
|
| 1093 | + * @return boolean True if it detects internal Facebook browser otherwise false |
|
| 1094 | + */ |
|
| 1095 | + protected function checkForFacebookIos() |
|
| 1096 | + { |
|
| 1097 | + if (stristr($this->_agent, 'FBIOS')) { |
|
| 1098 | + $this->setFacebook(true); |
|
| 1099 | + return true; |
|
| 1100 | + } |
|
| 1101 | + return false; |
|
| 1102 | + } |
|
| 1103 | + |
|
| 1104 | + /** |
|
| 1105 | + * Detect Version for the Safari browser on iOS devices |
|
| 1106 | + * @return boolean True if it detects the version correctly otherwise false |
|
| 1107 | + */ |
|
| 1108 | + protected function getSafariVersionOnIos() |
|
| 1109 | + { |
|
| 1110 | + $aresult = explode('/', stristr($this->_agent, 'Version')); |
|
| 1111 | + if (isset($aresult[1])) { |
|
| 1112 | + $aversion = explode(' ', $aresult[1]); |
|
| 1113 | + $this->setVersion($aversion[0]); |
|
| 1114 | + return true; |
|
| 1115 | + } |
|
| 1116 | + return false; |
|
| 1117 | + } |
|
| 1118 | + |
|
| 1119 | + /** |
|
| 1120 | + * Detect Version for the Chrome browser on iOS devices |
|
| 1121 | + * @return boolean True if it detects the version correctly otherwise false |
|
| 1122 | + */ |
|
| 1123 | + protected function getChromeVersionOnIos() |
|
| 1124 | + { |
|
| 1125 | + $aresult = explode('/', stristr($this->_agent, 'CriOS')); |
|
| 1126 | + if (isset($aresult[1])) { |
|
| 1127 | + $aversion = explode(' ', $aresult[1]); |
|
| 1128 | + $this->setVersion($aversion[0]); |
|
| 1129 | + $this->setBrowser(self::BROWSER_CHROME); |
|
| 1130 | + return true; |
|
| 1131 | + } |
|
| 1132 | + return false; |
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + /** |
|
| 1136 | + * Determine if the browser is iPhone or not (last updated 1.7) |
|
| 1137 | + * @return boolean True if the browser is iPhone otherwise false |
|
| 1138 | + */ |
|
| 1139 | + protected function checkBrowseriPhone() |
|
| 1140 | + { |
|
| 1141 | + if (stripos($this->_agent, 'iPhone') !== false) { |
|
| 1142 | + $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1143 | + $this->setBrowser(self::BROWSER_IPHONE); |
|
| 1144 | + $this->getSafariVersionOnIos(); |
|
| 1145 | + $this->getChromeVersionOnIos(); |
|
| 1146 | + $this->checkForFacebookIos(); |
|
| 1147 | + $this->setMobile(true); |
|
| 1148 | + return true; |
|
| 1149 | + } |
|
| 1150 | + return false; |
|
| 1151 | + } |
|
| 1152 | + |
|
| 1153 | + /** |
|
| 1154 | + * Determine if the browser is iPad or not (last updated 1.7) |
|
| 1155 | + * @return boolean True if the browser is iPad otherwise false |
|
| 1156 | + */ |
|
| 1157 | + protected function checkBrowseriPad() |
|
| 1158 | + { |
|
| 1159 | + if (stripos($this->_agent, 'iPad') !== false) { |
|
| 1160 | + $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1161 | + $this->setBrowser(self::BROWSER_IPAD); |
|
| 1162 | + $this->getSafariVersionOnIos(); |
|
| 1163 | + $this->getChromeVersionOnIos(); |
|
| 1164 | + $this->checkForFacebookIos(); |
|
| 1165 | + $this->setTablet(true); |
|
| 1166 | + return true; |
|
| 1167 | + } |
|
| 1168 | + return false; |
|
| 1169 | + } |
|
| 1170 | + |
|
| 1171 | + /** |
|
| 1172 | + * Determine if the browser is iPod or not (last updated 1.7) |
|
| 1173 | + * @return boolean True if the browser is iPod otherwise false |
|
| 1174 | + */ |
|
| 1175 | + protected function checkBrowseriPod() |
|
| 1176 | + { |
|
| 1177 | + if (stripos($this->_agent, 'iPod') !== false) { |
|
| 1178 | + $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1179 | + $this->setBrowser(self::BROWSER_IPOD); |
|
| 1180 | + $this->getSafariVersionOnIos(); |
|
| 1181 | + $this->getChromeVersionOnIos(); |
|
| 1182 | + $this->checkForFacebookIos(); |
|
| 1183 | + $this->setMobile(true); |
|
| 1184 | + return true; |
|
| 1185 | + } |
|
| 1186 | + return false; |
|
| 1187 | + } |
|
| 1188 | + |
|
| 1189 | + /** |
|
| 1190 | + * Determine if the browser is Android or not (last updated 1.7) |
|
| 1191 | + * @return boolean True if the browser is Android otherwise false |
|
| 1192 | + */ |
|
| 1193 | + protected function checkBrowserAndroid() |
|
| 1194 | + { |
|
| 1195 | + if (stripos($this->_agent, 'Android') !== false) { |
|
| 1196 | + $aresult = explode(' ', stristr($this->_agent, 'Android')); |
|
| 1197 | + if (isset($aresult[1])) { |
|
| 1198 | + $aversion = explode(' ', $aresult[1]); |
|
| 1199 | + $this->setVersion($aversion[0]); |
|
| 1200 | + } else { |
|
| 1201 | + $this->setVersion(self::VERSION_UNKNOWN); |
|
| 1202 | + } |
|
| 1203 | + if (stripos($this->_agent, 'Mobile') !== false) { |
|
| 1204 | + $this->setMobile(true); |
|
| 1205 | + } else { |
|
| 1206 | + $this->setTablet(true); |
|
| 1207 | + } |
|
| 1208 | + $this->setBrowser(self::BROWSER_ANDROID); |
|
| 1209 | + return true; |
|
| 1210 | + } |
|
| 1211 | + return false; |
|
| 1212 | + } |
|
| 1213 | + |
|
| 1214 | + /** |
|
| 1215 | + * Determine the user's platform (last updated 1.7) |
|
| 1216 | + */ |
|
| 1217 | + protected function checkPlatform() |
|
| 1218 | + { |
|
| 1219 | + if (stripos($this->_agent, 'windows') !== false) { |
|
| 1220 | + $this->_platform = self::PLATFORM_WINDOWS; |
|
| 1221 | + } else if (stripos($this->_agent, 'iPad') !== false) { |
|
| 1222 | + $this->_platform = self::PLATFORM_IPAD; |
|
| 1223 | + } else if (stripos($this->_agent, 'iPod') !== false) { |
|
| 1224 | + $this->_platform = self::PLATFORM_IPOD; |
|
| 1225 | + } else if (stripos($this->_agent, 'iPhone') !== false) { |
|
| 1226 | + $this->_platform = self::PLATFORM_IPHONE; |
|
| 1227 | + } elseif (stripos($this->_agent, 'mac') !== false) { |
|
| 1228 | + $this->_platform = self::PLATFORM_APPLE; |
|
| 1229 | + } elseif (stripos($this->_agent, 'android') !== false) { |
|
| 1230 | + $this->_platform = self::PLATFORM_ANDROID; |
|
| 1231 | + } elseif (stripos($this->_agent, 'linux') !== false) { |
|
| 1232 | + $this->_platform = self::PLATFORM_LINUX; |
|
| 1233 | + } else if (stripos($this->_agent, 'Nokia') !== false) { |
|
| 1234 | + $this->_platform = self::PLATFORM_NOKIA; |
|
| 1235 | + } else if (stripos($this->_agent, 'BlackBerry') !== false) { |
|
| 1236 | + $this->_platform = self::PLATFORM_BLACKBERRY; |
|
| 1237 | + } elseif (stripos($this->_agent, 'FreeBSD') !== false) { |
|
| 1238 | + $this->_platform = self::PLATFORM_FREEBSD; |
|
| 1239 | + } elseif (stripos($this->_agent, 'OpenBSD') !== false) { |
|
| 1240 | + $this->_platform = self::PLATFORM_OPENBSD; |
|
| 1241 | + } elseif (stripos($this->_agent, 'NetBSD') !== false) { |
|
| 1242 | + $this->_platform = self::PLATFORM_NETBSD; |
|
| 1243 | + } elseif (stripos($this->_agent, 'OpenSolaris') !== false) { |
|
| 1244 | + $this->_platform = self::PLATFORM_OPENSOLARIS; |
|
| 1245 | + } elseif (stripos($this->_agent, 'SunOS') !== false) { |
|
| 1246 | + $this->_platform = self::PLATFORM_SUNOS; |
|
| 1247 | + } elseif (stripos($this->_agent, 'OS\/2') !== false) { |
|
| 1248 | + $this->_platform = self::PLATFORM_OS2; |
|
| 1249 | + } elseif (stripos($this->_agent, 'BeOS') !== false) { |
|
| 1250 | + $this->_platform = self::PLATFORM_BEOS; |
|
| 1251 | + } elseif (stripos($this->_agent, 'win') !== false) { |
|
| 1252 | + $this->_platform = self::PLATFORM_WINDOWS; |
|
| 1253 | + } |
|
| 1254 | + |
|
| 1255 | + } |
|
| 1256 | + } |
|
| 1257 | 1257 | \ No newline at end of file |
@@ -353,9 +353,9 @@ |
||
| 353 | 353 | */ |
| 354 | 354 | public function __toString() |
| 355 | 355 | { |
| 356 | - return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n" . |
|
| 357 | - "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n" . |
|
| 358 | - "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n" . |
|
| 356 | + return "<strong>Browser Name:</strong> {$this->getBrowser()}<br/>\n". |
|
| 357 | + "<strong>Browser Version:</strong> {$this->getVersion()}<br/>\n". |
|
| 358 | + "<strong>Browser User Agent String:</strong> {$this->getUserAgent()}<br/>\n". |
|
| 359 | 359 | "<strong>Platform:</strong> {$this->getPlatform()}<br/>"; |
| 360 | 360 | } |
| 361 | 361 | |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | use SimpleCalendar\Abstracts\Feed; |
| 11 | 11 | use SimpleCalendar\Feeds\Admin\Grouped_Calendars_Admin; |
| 12 | 12 | |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -38,22 +38,22 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param string|Calendar $calendar |
| 40 | 40 | */ |
| 41 | - public function __construct( $calendar = '' ) { |
|
| 41 | + public function __construct($calendar = '') { |
|
| 42 | 42 | |
| 43 | - parent::__construct( $calendar ); |
|
| 43 | + parent::__construct($calendar); |
|
| 44 | 44 | |
| 45 | 45 | $this->type = 'grouped-calendars'; |
| 46 | - $this->name = __( 'Grouped Calendar', 'google-calendar-events' ); |
|
| 46 | + $this->name = __('Grouped Calendar', 'google-calendar-events'); |
|
| 47 | 47 | |
| 48 | - if ( $this->post_id > 0 ) { |
|
| 48 | + if ($this->post_id > 0) { |
|
| 49 | 49 | $this->set_source(); |
| 50 | - if ( ! is_admin() || defined( 'DOING_AJAX' ) ) { |
|
| 50 | + if ( ! is_admin() || defined('DOING_AJAX')) { |
|
| 51 | 51 | $this->events = $this->get_events(); |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 56 | - new Grouped_Calendars_Admin( $this ); |
|
| 55 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 56 | + new Grouped_Calendars_Admin($this); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -64,38 +64,38 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @param array $ids Array of calendar ids. |
| 66 | 66 | */ |
| 67 | - public function set_source( $ids = array() ) { |
|
| 67 | + public function set_source($ids = array()) { |
|
| 68 | 68 | |
| 69 | - $source = get_post_meta( $this->post_id, '_grouped_calendars_source', true ); |
|
| 69 | + $source = get_post_meta($this->post_id, '_grouped_calendars_source', true); |
|
| 70 | 70 | |
| 71 | - if ( 'ids' == $source ) { |
|
| 71 | + if ('ids' == $source) { |
|
| 72 | 72 | |
| 73 | - if ( empty( $ids ) ) { |
|
| 74 | - $ids = get_post_meta( $this->post_id, '_grouped_calendars_ids', true ); |
|
| 73 | + if (empty($ids)) { |
|
| 74 | + $ids = get_post_meta($this->post_id, '_grouped_calendars_ids', true); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $this->calendars_ids = ! empty( $ids ) && is_array( $ids ) ? array_map( 'absint', $ids ) : array(); |
|
| 77 | + $this->calendars_ids = ! empty($ids) && is_array($ids) ? array_map('absint', $ids) : array(); |
|
| 78 | 78 | |
| 79 | - } elseif ( 'category' == $source ) { |
|
| 79 | + } elseif ('category' == $source) { |
|
| 80 | 80 | |
| 81 | - $categories = get_post_meta( $this->post_id, '_grouped_calendars_category', true ); |
|
| 81 | + $categories = get_post_meta($this->post_id, '_grouped_calendars_category', true); |
|
| 82 | 82 | |
| 83 | - if ( $categories && is_array( $categories ) ) { |
|
| 83 | + if ($categories && is_array($categories)) { |
|
| 84 | 84 | |
| 85 | 85 | $tax_query = array( |
| 86 | 86 | 'taxonomy' => 'calendar_category', |
| 87 | 87 | 'field' => 'term_id', |
| 88 | - 'terms' => array_map( 'absint', $categories ), |
|
| 88 | + 'terms' => array_map('absint', $categories), |
|
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | - $calendars = get_posts( array( |
|
| 91 | + $calendars = get_posts(array( |
|
| 92 | 92 | 'post_type' => 'calendar', |
| 93 | - 'tax_query' => array( $tax_query ), |
|
| 93 | + 'tax_query' => array($tax_query), |
|
| 94 | 94 | 'nopaging' => true, |
| 95 | 95 | 'fields' => 'ids', |
| 96 | - ) ); |
|
| 96 | + )); |
|
| 97 | 97 | |
| 98 | - $this->calendars_ids = ! empty( $calendars ) && is_array( $calendars ) ? $calendars : array(); |
|
| 98 | + $this->calendars_ids = ! empty($calendars) && is_array($calendars) ? $calendars : array(); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -111,57 +111,57 @@ discard block |
||
| 111 | 111 | public function get_events() { |
| 112 | 112 | |
| 113 | 113 | $ids = $this->calendars_ids; |
| 114 | - $events = get_transient( '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type ); |
|
| 114 | + $events = get_transient('_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type); |
|
| 115 | 115 | |
| 116 | - if ( empty( $events ) && ! empty( $ids ) && is_array( $ids ) ) { |
|
| 116 | + if (empty($events) && ! empty($ids) && is_array($ids)) { |
|
| 117 | 117 | |
| 118 | 118 | $events = array(); |
| 119 | 119 | |
| 120 | - foreach ( $ids as $cal_id ) { |
|
| 120 | + foreach ($ids as $cal_id) { |
|
| 121 | 121 | |
| 122 | - $calendar = simcal_get_calendar( intval( $cal_id ) ); |
|
| 122 | + $calendar = simcal_get_calendar(intval($cal_id)); |
|
| 123 | 123 | |
| 124 | - simcal_delete_feed_transients( $cal_id ); |
|
| 124 | + simcal_delete_feed_transients($cal_id); |
|
| 125 | 125 | |
| 126 | - if ( $calendar instanceof Calendar ) { |
|
| 126 | + if ($calendar instanceof Calendar) { |
|
| 127 | 127 | |
| 128 | 128 | // Sometimes the calendars might have events at the same time from different calendars |
| 129 | 129 | // When merging the arrays together some of the events will be lost because the keys are the same and one will overwrite the other |
| 130 | 130 | // This snippet checks if the key already exists in the master events array and if it does it subtracts 1 from it to make the key unique and then unsets the original key. |
| 131 | - foreach( $calendar->events as $k => $v ) { |
|
| 132 | - $calendar->events[ $this->update_array_timestamp( $events, $k ) ] = $v; |
|
| 131 | + foreach ($calendar->events as $k => $v) { |
|
| 132 | + $calendar->events[$this->update_array_timestamp($events, $k)] = $v; |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $events = is_array( $calendar->events ) ? $events + $calendar->events : $events; |
|
| 135 | + $events = is_array($calendar->events) ? $events + $calendar->events : $events; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if ( ! empty( $events ) ) { |
|
| 140 | + if ( ! empty($events)) { |
|
| 141 | 141 | |
| 142 | 142 | // Trim events to set the earliest one as specified in feed settings. |
| 143 | - $earliest_event = intval( $this->time_min ); |
|
| 144 | - if ( $earliest_event > 0 ) { |
|
| 145 | - $events = $this->array_filter_key( $events, array( $this, 'filter_events_before' ) ); |
|
| 143 | + $earliest_event = intval($this->time_min); |
|
| 144 | + if ($earliest_event > 0) { |
|
| 145 | + $events = $this->array_filter_key($events, array($this, 'filter_events_before')); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // Trim events to set the latest one as specified in feed settings. |
| 149 | - $latest_event = intval( $this->time_max ); |
|
| 150 | - if ( $latest_event > 0 ) { |
|
| 151 | - $events = $this->array_filter_key( $events, array( $this, 'filter_events_after' ) ); |
|
| 149 | + $latest_event = intval($this->time_max); |
|
| 150 | + if ($latest_event > 0) { |
|
| 151 | + $events = $this->array_filter_key($events, array($this, 'filter_events_after')); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | set_transient( |
| 155 | - '_simple-calendar_feed_id_' . strval( $this->post_id ) . '_' . $this->type, |
|
| 155 | + '_simple-calendar_feed_id_'.strval($this->post_id).'_'.$this->type, |
|
| 156 | 156 | $events, |
| 157 | - absint( $this->cache ) |
|
| 157 | + absint($this->cache) |
|
| 158 | 158 | ); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Sort events by start time before returning |
| 164 | - uasort( $events, array( $this, 'sort_by_start_time' ) ); |
|
| 164 | + uasort($events, array($this, 'sort_by_start_time')); |
|
| 165 | 165 | |
| 166 | 166 | return $events; |
| 167 | 167 | } |
@@ -169,10 +169,10 @@ discard block |
||
| 169 | 169 | /* |
| 170 | 170 | * Recursive function to adjust the timestamp array indices that are the same. |
| 171 | 171 | */ |
| 172 | - public function update_array_timestamp( $arr, $i ) { |
|
| 172 | + public function update_array_timestamp($arr, $i) { |
|
| 173 | 173 | |
| 174 | - if ( array_key_exists( $i, $arr ) ) { |
|
| 175 | - $i = $this->update_array_timestamp( $arr, $i - 1 ); |
|
| 174 | + if (array_key_exists($i, $arr)) { |
|
| 175 | + $i = $this->update_array_timestamp($arr, $i - 1); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | return $i; |
@@ -184,12 +184,12 @@ discard block |
||
| 184 | 184 | * @since 3.0.13 |
| 185 | 185 | * @access private |
| 186 | 186 | */ |
| 187 | - private function sort_by_start_time( $a, $b ) { |
|
| 188 | - if ( $a == $b ) { |
|
| 187 | + private function sort_by_start_time($a, $b) { |
|
| 188 | + if ($a == $b) { |
|
| 189 | 189 | return 0; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - return ( $a[0]->start < $b[0]->start ) ? -1 : 1; |
|
| 192 | + return ($a[0]->start < $b[0]->start) ? -1 : 1; |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | |
@@ -207,9 +207,9 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return array |
| 209 | 209 | */ |
| 210 | - private function array_filter_key( array $array, $callback ) { |
|
| 211 | - $matched_keys = array_filter( array_keys( $array ), $callback ); |
|
| 212 | - return array_intersect_key( $array, array_flip( $matched_keys ) ); |
|
| 210 | + private function array_filter_key(array $array, $callback) { |
|
| 211 | + $matched_keys = array_filter(array_keys($array), $callback); |
|
| 212 | + return array_intersect_key($array, array_flip($matched_keys)); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -222,9 +222,9 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @return bool |
| 224 | 224 | */ |
| 225 | - private function filter_events_before( $event ) { |
|
| 226 | - if ( $this->time_min !== 0 ) { |
|
| 227 | - return intval( $event ) > intval( $this->time_min ); |
|
| 225 | + private function filter_events_before($event) { |
|
| 226 | + if ($this->time_min !== 0) { |
|
| 227 | + return intval($event) > intval($this->time_min); |
|
| 228 | 228 | } |
| 229 | 229 | return true; |
| 230 | 230 | } |
@@ -239,9 +239,9 @@ discard block |
||
| 239 | 239 | * |
| 240 | 240 | * @return bool |
| 241 | 241 | */ |
| 242 | - private function filter_events_after( $event ) { |
|
| 243 | - if ( $this->time_max !== 0 ) { |
|
| 244 | - return intval( $event ) < intval( $this->time_max ); |
|
| 242 | + private function filter_events_after($event) { |
|
| 243 | + if ($this->time_max !== 0) { |
|
| 244 | + return intval($event) < intval($this->time_max); |
|
| 245 | 245 | } |
| 246 | 246 | return true; |
| 247 | 247 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts as Object; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -31,27 +31,27 @@ discard block |
||
| 31 | 31 | public function __construct() { |
| 32 | 32 | |
| 33 | 33 | // Add default feed type. |
| 34 | - add_filter( 'simcal_get_feed_types', function( $feed_types ) { |
|
| 35 | - return array_merge( $feed_types, array( |
|
| 34 | + add_filter('simcal_get_feed_types', function($feed_types) { |
|
| 35 | + return array_merge($feed_types, array( |
|
| 36 | 36 | 'google', |
| 37 | 37 | 'grouped-calendars', |
| 38 | - ) ); |
|
| 39 | - }, 10, 1 ); |
|
| 38 | + )); |
|
| 39 | + }, 10, 1); |
|
| 40 | 40 | |
| 41 | 41 | // Add default calendar type. |
| 42 | - add_filter( 'simcal_get_calendar_types', function( $calendar_types ) { |
|
| 43 | - return array_merge( $calendar_types, array( |
|
| 42 | + add_filter('simcal_get_calendar_types', function($calendar_types) { |
|
| 43 | + return array_merge($calendar_types, array( |
|
| 44 | 44 | 'default-calendar' => array( |
| 45 | 45 | 'grid', |
| 46 | 46 | 'list', |
| 47 | 47 | ), |
| 48 | - ) ); |
|
| 49 | - }, 10, 1 ); |
|
| 48 | + )); |
|
| 49 | + }, 10, 1); |
|
| 50 | 50 | |
| 51 | 51 | // Add default admin objects. |
| 52 | - if ( $is_admin = is_admin() ) { |
|
| 53 | - add_filter( 'simcal_get_admin_pages', function( $admin_pages ) { |
|
| 54 | - return array_merge( $admin_pages, array( |
|
| 52 | + if ($is_admin = is_admin()) { |
|
| 53 | + add_filter('simcal_get_admin_pages', function($admin_pages) { |
|
| 54 | + return array_merge($admin_pages, array( |
|
| 55 | 55 | 'add-ons' => array( |
| 56 | 56 | 'add-ons', |
| 57 | 57 | ), |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | 'tools' => array( |
| 64 | 64 | 'system-status', |
| 65 | 65 | ), |
| 66 | - ) ); |
|
| 67 | - }, 10, 1 ); |
|
| 66 | + )); |
|
| 67 | + }, 10, 1); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - do_action( 'simcal_load_objects', $is_admin ); |
|
| 70 | + do_action('simcal_load_objects', $is_admin); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -78,8 +78,8 @@ discard block |
||
| 78 | 78 | * @return array |
| 79 | 79 | */ |
| 80 | 80 | public function get_feed_types() { |
| 81 | - $array = apply_filters( 'simcal_get_feed_types', array() ); |
|
| 82 | - ksort( $array ); |
|
| 81 | + $array = apply_filters('simcal_get_feed_types', array()); |
|
| 82 | + ksort($array); |
|
| 83 | 83 | return $array; |
| 84 | 84 | } |
| 85 | 85 | |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | * @return array |
| 92 | 92 | */ |
| 93 | 93 | public function get_calendar_types() { |
| 94 | - $array = apply_filters( 'simcal_get_calendar_types', array() ); |
|
| 95 | - ksort( $array ); |
|
| 94 | + $array = apply_filters('simcal_get_calendar_types', array()); |
|
| 95 | + ksort($array); |
|
| 96 | 96 | return $array; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @return array |
| 105 | 105 | */ |
| 106 | 106 | public function get_admin_pages() { |
| 107 | - return apply_filters( 'simcal_get_admin_pages', array() ); |
|
| 107 | + return apply_filters('simcal_get_admin_pages', array()); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -118,30 +118,30 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @return null|Object\Calendar |
| 120 | 120 | */ |
| 121 | - public function get_calendar( $object ) { |
|
| 121 | + public function get_calendar($object) { |
|
| 122 | 122 | |
| 123 | - if ( is_string( $object ) ) { |
|
| 124 | - return ! empty( $object ) ? $this->get_object( $object, 'calendar', '' ) : null; |
|
| 123 | + if (is_string($object)) { |
|
| 124 | + return ! empty($object) ? $this->get_object($object, 'calendar', '') : null; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - if ( is_object( $object ) ) { |
|
| 128 | - if ( $object instanceof Object\Calendar ) { |
|
| 129 | - return $this->get_object( $object->type, 'feed', $object ); |
|
| 130 | - } elseif ( $object instanceof \WP_Post ) { |
|
| 131 | - if ( $type = wp_get_object_terms( $object->ID, 'calendar_type' ) ) { |
|
| 132 | - $name = sanitize_title( current( $type )->name ); |
|
| 133 | - return $this->get_object( $name, 'calendar', $object ); |
|
| 127 | + if (is_object($object)) { |
|
| 128 | + if ($object instanceof Object\Calendar) { |
|
| 129 | + return $this->get_object($object->type, 'feed', $object); |
|
| 130 | + } elseif ($object instanceof \WP_Post) { |
|
| 131 | + if ($type = wp_get_object_terms($object->ID, 'calendar_type')) { |
|
| 132 | + $name = sanitize_title(current($type)->name); |
|
| 133 | + return $this->get_object($name, 'calendar', $object); |
|
| 134 | 134 | } |
| 135 | - } elseif ( isset( $object->type ) && isset( $object->id ) ) { |
|
| 136 | - return $this->get_object( $object->type, 'calendar', $object->id ); |
|
| 135 | + } elseif (isset($object->type) && isset($object->id)) { |
|
| 136 | + return $this->get_object($object->type, 'calendar', $object->id); |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - if ( is_int( $object ) ) { |
|
| 141 | - $post = get_post( $object ); |
|
| 142 | - if ( $post && ( $type = wp_get_object_terms( $post->ID, 'calendar_type' ) ) ) { |
|
| 143 | - $name = sanitize_title( current( $type )->name ); |
|
| 144 | - return $this->get_object( $name, 'calendar', $post ); |
|
| 140 | + if (is_int($object)) { |
|
| 141 | + $post = get_post($object); |
|
| 142 | + if ($post && ($type = wp_get_object_terms($post->ID, 'calendar_type'))) { |
|
| 143 | + $name = sanitize_title(current($type)->name); |
|
| 144 | + return $this->get_object($name, 'calendar', $post); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | |
@@ -158,20 +158,20 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return null|Object\Calendar_View |
| 160 | 160 | */ |
| 161 | - public function get_calendar_view( $id = 0, $name = '' ) { |
|
| 161 | + public function get_calendar_view($id = 0, $name = '') { |
|
| 162 | 162 | |
| 163 | - if ( ! $name && $id > 0 ) { |
|
| 163 | + if ( ! $name && $id > 0) { |
|
| 164 | 164 | |
| 165 | - $calendar_view = get_post_meta( $id, '_calendar_view', true ); |
|
| 165 | + $calendar_view = get_post_meta($id, '_calendar_view', true); |
|
| 166 | 166 | |
| 167 | - if ( $terms = wp_get_object_terms( $id, 'calendar_type' ) ) { |
|
| 168 | - $calendar_type = sanitize_title( current( $terms )->name ); |
|
| 169 | - $name = isset( $calendar_view[ $calendar_type ] ) ? $calendar_type . '-' . $calendar_view[ $calendar_type ] : ''; |
|
| 167 | + if ($terms = wp_get_object_terms($id, 'calendar_type')) { |
|
| 168 | + $calendar_type = sanitize_title(current($terms)->name); |
|
| 169 | + $name = isset($calendar_view[$calendar_type]) ? $calendar_type.'-'.$calendar_view[$calendar_type] : ''; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - return $name ? $this->get_object( $name, 'calendar-view', '' ) : null; |
|
| 174 | + return $name ? $this->get_object($name, 'calendar-view', '') : null; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -185,41 +185,41 @@ discard block |
||
| 185 | 185 | * |
| 186 | 186 | * @return null|Object\Feed |
| 187 | 187 | */ |
| 188 | - public function get_feed( $object ) { |
|
| 188 | + public function get_feed($object) { |
|
| 189 | 189 | |
| 190 | - if ( is_string( $object ) ) { |
|
| 191 | - return ! empty( $object ) ? $this->get_object( $object, 'feed', '' ) : null; |
|
| 190 | + if (is_string($object)) { |
|
| 191 | + return ! empty($object) ? $this->get_object($object, 'feed', '') : null; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if ( is_object( $object ) ) { |
|
| 195 | - if ( $object instanceof Object\Calendar ) { |
|
| 194 | + if (is_object($object)) { |
|
| 195 | + if ($object instanceof Object\Calendar) { |
|
| 196 | 196 | $feed_name = ''; |
| 197 | - if ( empty( $object->feed ) ) { |
|
| 198 | - if ( $feed_type = wp_get_object_terms( $object->id, 'feed_type' ) ) { |
|
| 199 | - $feed_name = sanitize_title( current( $feed_type )->name ); |
|
| 197 | + if (empty($object->feed)) { |
|
| 198 | + if ($feed_type = wp_get_object_terms($object->id, 'feed_type')) { |
|
| 199 | + $feed_name = sanitize_title(current($feed_type)->name); |
|
| 200 | 200 | } |
| 201 | 201 | } else { |
| 202 | 202 | $feed_name = $object->feed; |
| 203 | 203 | } |
| 204 | - return $this->get_object( $feed_name, 'feed', $object ); |
|
| 205 | - } elseif ( $object instanceof \WP_Post ) { |
|
| 206 | - $calendar = $this->get_calendar( $object ); |
|
| 204 | + return $this->get_object($feed_name, 'feed', $object); |
|
| 205 | + } elseif ($object instanceof \WP_Post) { |
|
| 206 | + $calendar = $this->get_calendar($object); |
|
| 207 | 207 | |
| 208 | - if ( isset( $calendar->feed ) ) { |
|
| 209 | - return $this->get_object( $calendar->feed, 'feed', $calendar ); |
|
| 208 | + if (isset($calendar->feed)) { |
|
| 209 | + return $this->get_object($calendar->feed, 'feed', $calendar); |
|
| 210 | 210 | } else { |
| 211 | 211 | return null; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | |
| 215 | - } elseif ( isset( $object->feed ) && isset( $object->id ) ) { |
|
| 216 | - return $this->get_object( $object->feed, 'feed', $object ); |
|
| 215 | + } elseif (isset($object->feed) && isset($object->id)) { |
|
| 216 | + return $this->get_object($object->feed, 'feed', $object); |
|
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - if ( is_int( $object ) ) { |
|
| 221 | - $calendar = $this->get_calendar( $object ); |
|
| 222 | - return isset( $calendar->feed ) ? $this->get_object( $calendar->feed, 'feed', $calendar ) : null; |
|
| 220 | + if (is_int($object)) { |
|
| 221 | + $calendar = $this->get_calendar($object); |
|
| 222 | + return isset($calendar->feed) ? $this->get_object($calendar->feed, 'feed', $calendar) : null; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | return null; |
@@ -235,13 +235,13 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @return null|Object\Field |
| 237 | 237 | */ |
| 238 | - public function get_field( $args, $name = '' ) { |
|
| 238 | + public function get_field($args, $name = '') { |
|
| 239 | 239 | |
| 240 | - if ( empty( $name ) ) { |
|
| 241 | - $name = isset( $args['type'] ) ? $args['type'] : false; |
|
| 240 | + if (empty($name)) { |
|
| 241 | + $name = isset($args['type']) ? $args['type'] : false; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - return $name ? $this->get_object( $name, 'field', $args ) : null; |
|
| 244 | + return $name ? $this->get_object($name, 'field', $args) : null; |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -253,8 +253,8 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return null|Object\Admin_Page |
| 255 | 255 | */ |
| 256 | - public function get_admin_page( $name ) { |
|
| 257 | - return $name ? $this->get_object( $name, 'admin-page' ) : null; |
|
| 256 | + public function get_admin_page($name) { |
|
| 257 | + return $name ? $this->get_object($name, 'admin-page') : null; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return null|Object |
| 271 | 271 | */ |
| 272 | - private function get_object( $name, $type, $args = '' ) { |
|
| 272 | + private function get_object($name, $type, $args = '') { |
|
| 273 | 273 | |
| 274 | 274 | $types = array( |
| 275 | 275 | 'admin-page', |
@@ -279,11 +279,11 @@ discard block |
||
| 279 | 279 | 'field', |
| 280 | 280 | ); |
| 281 | 281 | |
| 282 | - if ( in_array( $type, $types ) ) { |
|
| 282 | + if (in_array($type, $types)) { |
|
| 283 | 283 | |
| 284 | - $class_name = $this->make_class_name( $name, $type ); |
|
| 285 | - $parent = '\\' . __NAMESPACE__ . '\Abstracts\\' . implode( '_', array_map( 'ucfirst', explode( '-', $type ) ) ); |
|
| 286 | - $class = class_exists( $class_name ) ? new $class_name( $args ) : false; |
|
| 284 | + $class_name = $this->make_class_name($name, $type); |
|
| 285 | + $parent = '\\'.__NAMESPACE__.'\Abstracts\\'.implode('_', array_map('ucfirst', explode('-', $type))); |
|
| 286 | + $class = class_exists($class_name) ? new $class_name($args) : false; |
|
| 287 | 287 | |
| 288 | 288 | return $class instanceof $parent ? $class : null; |
| 289 | 289 | } |
@@ -305,25 +305,25 @@ discard block |
||
| 305 | 305 | * |
| 306 | 306 | * @return string The class name complete with its full namespace. |
| 307 | 307 | */ |
| 308 | - private function make_class_name( $name, $type ) { |
|
| 309 | - |
|
| 310 | - if ( 'calendar' == $type ) { |
|
| 311 | - $namespace = '\\' . __NAMESPACE__ . '\Calendars\\'; |
|
| 312 | - } elseif ( 'calendar-view' == $type ) { |
|
| 313 | - $namespace = '\\' . __NAMESPACE__ . '\Calendars\Views\\'; |
|
| 314 | - } elseif ( 'feed' == $type ) { |
|
| 315 | - $namespace = '\\' . __NAMESPACE__ . '\Feeds\\'; |
|
| 316 | - } elseif ( 'field' == $type ) { |
|
| 317 | - $namespace = '\\' . __NAMESPACE__ . '\Admin\Fields\\'; |
|
| 318 | - } elseif ( 'admin-page' == $type ) { |
|
| 319 | - $namespace = '\\' . __NAMESPACE__ . '\Admin\Pages\\'; |
|
| 308 | + private function make_class_name($name, $type) { |
|
| 309 | + |
|
| 310 | + if ('calendar' == $type) { |
|
| 311 | + $namespace = '\\'.__NAMESPACE__.'\Calendars\\'; |
|
| 312 | + } elseif ('calendar-view' == $type) { |
|
| 313 | + $namespace = '\\'.__NAMESPACE__.'\Calendars\Views\\'; |
|
| 314 | + } elseif ('feed' == $type) { |
|
| 315 | + $namespace = '\\'.__NAMESPACE__.'\Feeds\\'; |
|
| 316 | + } elseif ('field' == $type) { |
|
| 317 | + $namespace = '\\'.__NAMESPACE__.'\Admin\Fields\\'; |
|
| 318 | + } elseif ('admin-page' == $type) { |
|
| 319 | + $namespace = '\\'.__NAMESPACE__.'\Admin\Pages\\'; |
|
| 320 | 320 | } else { |
| 321 | 321 | return ''; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $class_name = implode( '_', array_map( 'ucfirst', explode( '-', $name ) ) ); |
|
| 324 | + $class_name = implode('_', array_map('ucfirst', explode('-', $name))); |
|
| 325 | 325 | |
| 326 | - return $namespace . $class_name; |
|
| 326 | + return $namespace.$class_name; |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Feeds\Grouped_Calendars; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -34,15 +34,15 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param Grouped_Calendars $feed |
| 36 | 36 | */ |
| 37 | - public function __construct( Grouped_Calendars $feed ) { |
|
| 37 | + public function __construct(Grouped_Calendars $feed) { |
|
| 38 | 38 | |
| 39 | 39 | $this->feed = $feed; |
| 40 | 40 | |
| 41 | - if ( 'calendar' == simcal_is_admin_screen() ) { |
|
| 42 | - add_filter( 'simcal_settings_meta_tabs_li', array( $this, 'add_settings_meta_tab_li' ), 10, 1 ); |
|
| 43 | - add_action( 'simcal_settings_meta_panels', array( $this, 'add_settings_meta_panel' ), 10, 1 ); |
|
| 41 | + if ('calendar' == simcal_is_admin_screen()) { |
|
| 42 | + add_filter('simcal_settings_meta_tabs_li', array($this, 'add_settings_meta_tab_li'), 10, 1); |
|
| 43 | + add_action('simcal_settings_meta_panels', array($this, 'add_settings_meta_panel'), 10, 1); |
|
| 44 | 44 | } |
| 45 | - add_action( 'simcal_process_settings_meta', array( $this, 'process_meta' ), 10, 1 ); |
|
| 45 | + add_action('simcal_process_settings_meta', array($this, 'process_meta'), 10, 1); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | - public function add_settings_meta_tab_li( $tabs ) { |
|
| 58 | - return array_merge( $tabs, array( |
|
| 57 | + public function add_settings_meta_tab_li($tabs) { |
|
| 58 | + return array_merge($tabs, array( |
|
| 59 | 59 | 'grouped-calendars' => array( |
| 60 | 60 | 'label' => $this->feed->name, |
| 61 | 61 | 'target' => 'grouped-calendars-settings-panel', |
@@ -75,40 +75,40 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @param int $post_id |
| 77 | 77 | */ |
| 78 | - public function add_settings_meta_panel( $post_id ) { |
|
| 78 | + public function add_settings_meta_panel($post_id) { |
|
| 79 | 79 | |
| 80 | 80 | ?> |
| 81 | 81 | <div id="grouped-calendars-settings-panel" class="simcal-panel"> |
| 82 | 82 | <table> |
| 83 | 83 | <thead> |
| 84 | - <tr><th colspan="2"><?php _e( 'Grouped Calendar Settings', 'google-calendar-events' ); ?></th></tr> |
|
| 84 | + <tr><th colspan="2"><?php _e('Grouped Calendar Settings', 'google-calendar-events'); ?></th></tr> |
|
| 85 | 85 | </thead> |
| 86 | 86 | <tbody class="simcal-panel-section"> |
| 87 | 87 | <tr class="simcal-panel-field"> |
| 88 | - <th><label for="_grouped_calendars_source"><?php _e( 'Get Calendars From', 'google-calendar-events' ); ?></label></th> |
|
| 88 | + <th><label for="_grouped_calendars_source"><?php _e('Get Calendars From', 'google-calendar-events'); ?></label></th> |
|
| 89 | 89 | <td> |
| 90 | 90 | <?php |
| 91 | 91 | |
| 92 | - $source = esc_attr( get_post_meta( $post_id, '_grouped_calendars_source', true ) ); |
|
| 93 | - $source = empty( $source ) ? 'ids' : $source; |
|
| 92 | + $source = esc_attr(get_post_meta($post_id, '_grouped_calendars_source', true)); |
|
| 93 | + $source = empty($source) ? 'ids' : $source; |
|
| 94 | 94 | |
| 95 | 95 | ?> |
| 96 | 96 | <select name="_grouped_calendars_source" |
| 97 | 97 | id="_grouped_calendars_source" |
| 98 | 98 | class="simcal-field simcal-field-select simcal-field-inline simcal-field-show-other" |
| 99 | 99 | data-show-field-on-choice="true"> |
| 100 | - <option value="ids" data-show-field="_grouped_calendars_ids" <?php selected( 'ids', $source, true ); ?>><?php _e( 'Manual selection', 'google-calendar-events' ); ?></option> |
|
| 101 | - <option value="category" data-show-field="_grouped_calendars_category" <?php selected( 'category', $source, true ); ?>><?php _e( 'Category', 'google-calendar-events' ); ?></option> |
|
| 100 | + <option value="ids" data-show-field="_grouped_calendars_ids" <?php selected('ids', $source, true); ?>><?php _e('Manual selection', 'google-calendar-events'); ?></option> |
|
| 101 | + <option value="category" data-show-field="_grouped_calendars_category" <?php selected('category', $source, true); ?>><?php _e('Category', 'google-calendar-events'); ?></option> |
|
| 102 | 102 | </select> |
| 103 | - <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e( 'Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events' ); ?>"></i> |
|
| 103 | + <i class="simcal-icon-help simcal-help-tip" data-tip="<?php _e('Choose from which calendar feeds you want to get events from. Choose them individually or select all those belonging to calendar feed categories.', 'google-calendar-events'); ?>"></i> |
|
| 104 | 104 | <br><br> |
| 105 | 105 | <?php |
| 106 | 106 | |
| 107 | - $cals = simcal_get_calendars( $post_id ); |
|
| 108 | - $meta = get_post_meta( $post_id, '_grouped_calendars_ids', true ); |
|
| 109 | - $ids = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ) : absint( $meta ); |
|
| 107 | + $cals = simcal_get_calendars($post_id); |
|
| 108 | + $meta = get_post_meta($post_id, '_grouped_calendars_ids', true); |
|
| 109 | + $ids = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : absint($meta); |
|
| 110 | 110 | |
| 111 | - simcal_print_field( array( |
|
| 111 | + simcal_print_field(array( |
|
| 112 | 112 | 'type' => 'select', |
| 113 | 113 | 'multiselect' => 'multiselect', |
| 114 | 114 | 'name' => '_grouped_calendars_ids', |
@@ -116,25 +116,25 @@ discard block |
||
| 116 | 116 | 'value' => $ids !== 0 ? $ids : '', |
| 117 | 117 | 'options' => $cals, |
| 118 | 118 | 'enhanced' => 'enhanced', |
| 119 | - 'style' => 'ids' == $source ? '' : array( 'display' => 'none' ), |
|
| 119 | + 'style' => 'ids' == $source ? '' : array('display' => 'none'), |
|
| 120 | 120 | 'attributes' => array( |
| 121 | - 'data-noresults' => __( 'No results found.', 'google-calendar-events' ), |
|
| 121 | + 'data-noresults' => __('No results found.', 'google-calendar-events'), |
|
| 122 | 122 | ), |
| 123 | 123 | )); |
| 124 | 124 | |
| 125 | - $meta = get_post_meta( $post_id, '_grouped_calendars_category', true ); |
|
| 126 | - $category = $meta && is_array( $meta ) ? implode( ',', array_map( 'absint', $meta ) ): ''; |
|
| 125 | + $meta = get_post_meta($post_id, '_grouped_calendars_category', true); |
|
| 126 | + $category = $meta && is_array($meta) ? implode(',', array_map('absint', $meta)) : ''; |
|
| 127 | 127 | |
| 128 | - $terms = get_terms( 'calendar_category' ); |
|
| 128 | + $terms = get_terms('calendar_category'); |
|
| 129 | 129 | |
| 130 | - if ( ! empty( $terms ) ) { |
|
| 130 | + if ( ! empty($terms)) { |
|
| 131 | 131 | |
| 132 | 132 | $categories = array(); |
| 133 | - foreach ( $terms as $term ) { |
|
| 134 | - $categories[ $term->term_id ] = $term->name; |
|
| 133 | + foreach ($terms as $term) { |
|
| 134 | + $categories[$term->term_id] = $term->name; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - simcal_print_field( array( |
|
| 137 | + simcal_print_field(array( |
|
| 138 | 138 | 'type' => 'select', |
| 139 | 139 | 'multiselect' => 'multiselect', |
| 140 | 140 | 'name' => '_grouped_calendars_category', |
@@ -142,17 +142,17 @@ discard block |
||
| 142 | 142 | 'value' => $category, |
| 143 | 143 | 'options' => $categories, |
| 144 | 144 | 'enhanced' => 'enhanced', |
| 145 | - 'style' => 'category' == $source ? '' : array( 'display' => 'none' ), |
|
| 145 | + 'style' => 'category' == $source ? '' : array('display' => 'none'), |
|
| 146 | 146 | 'attributes' => array( |
| 147 | - 'data-noresults' => __( 'No results found.', 'google-calendar-events' ), |
|
| 147 | + 'data-noresults' => __('No results found.', 'google-calendar-events'), |
|
| 148 | 148 | ), |
| 149 | - ) ); |
|
| 149 | + )); |
|
| 150 | 150 | |
| 151 | 151 | } else { |
| 152 | 152 | |
| 153 | 153 | $style = 'category' == $source ? '' : 'display: none;'; |
| 154 | 154 | $style .= ' width: 100%; max-width: 500px'; |
| 155 | - echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="' . $style . '" placeholder="' . __( 'There are no calendar categories yet.', 'google-calendar-events' ) . '" />'; |
|
| 155 | + echo '<input type="text" disabled="disabled" name="_grouped_calendars_category" id="_grouped_calendars_category" style="'.$style.'" placeholder="'.__('There are no calendar categories yet.', 'google-calendar-events').'" />'; |
|
| 156 | 156 | |
| 157 | 157 | } |
| 158 | 158 | |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | * |
| 174 | 174 | * @param int $post_id |
| 175 | 175 | */ |
| 176 | - public function process_meta( $post_id ) { |
|
| 176 | + public function process_meta($post_id) { |
|
| 177 | 177 | |
| 178 | - $source = isset( $_POST['_grouped_calendars_source'] ) ? sanitize_key( $_POST['_grouped_calendars_source'] ) : 'ids'; |
|
| 179 | - update_post_meta( $post_id, '_grouped_calendars_source', $source ); |
|
| 178 | + $source = isset($_POST['_grouped_calendars_source']) ? sanitize_key($_POST['_grouped_calendars_source']) : 'ids'; |
|
| 179 | + update_post_meta($post_id, '_grouped_calendars_source', $source); |
|
| 180 | 180 | |
| 181 | - $ids = isset( $_POST['_grouped_calendars_ids'] ) ? array_map( 'absint', $_POST['_grouped_calendars_ids'] ) : ''; |
|
| 182 | - update_post_meta( $post_id, '_grouped_calendars_ids', $ids ); |
|
| 181 | + $ids = isset($_POST['_grouped_calendars_ids']) ? array_map('absint', $_POST['_grouped_calendars_ids']) : ''; |
|
| 182 | + update_post_meta($post_id, '_grouped_calendars_ids', $ids); |
|
| 183 | 183 | |
| 184 | - $category = isset( $_POST['_grouped_calendars_category'] ) ? array_map( 'absint', $_POST['_grouped_calendars_category'] ) : ''; |
|
| 185 | - update_post_meta( $post_id, '_grouped_calendars_category', $category ); |
|
| 184 | + $category = isset($_POST['_grouped_calendars_category']) ? array_map('absint', $_POST['_grouped_calendars_category']) : ''; |
|
| 185 | + update_post_meta($post_id, '_grouped_calendars_category', $category); |
|
| 186 | 186 | |
| 187 | 187 | } |
| 188 | 188 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Admin\Metaboxes as Metabox; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function __construct() { |
| 46 | 46 | |
| 47 | - $settings = get_option( 'simple-calendar_settings_calendars' ); |
|
| 48 | - if ( isset( $settings['general']['attach_calendars_posts'] ) ) { |
|
| 47 | + $settings = get_option('simple-calendar_settings_calendars'); |
|
| 48 | + if (isset($settings['general']['attach_calendars_posts'])) { |
|
| 49 | 49 | $this->post_types = $settings['general']['attach_calendars_posts']; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | new Metabox\Settings(); |
| 54 | 54 | new Metabox\Attach_Calendar(); |
| 55 | 55 | new Metabox\Newsletter(); |
| 56 | - do_action( 'simcal_load_meta_boxes' ); |
|
| 56 | + do_action('simcal_load_meta_boxes'); |
|
| 57 | 57 | |
| 58 | 58 | // Add meta boxes. |
| 59 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 ); |
|
| 59 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 30); |
|
| 60 | 60 | |
| 61 | 61 | // Process meta boxes. |
| 62 | - add_action( 'simcal_save_settings_meta','\SimpleCalendar\Admin\Metaboxes\Settings::save', 10, 2 ); |
|
| 63 | - add_action( 'simcal_save_attach_calendar_meta','\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::save', 10, 2 ); |
|
| 62 | + add_action('simcal_save_settings_meta', '\SimpleCalendar\Admin\Metaboxes\Settings::save', 10, 2); |
|
| 63 | + add_action('simcal_save_attach_calendar_meta', '\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::save', 10, 2); |
|
| 64 | 64 | |
| 65 | 65 | // Save meta boxes data. |
| 66 | - add_action( 'save_post', array( $this, 'save_meta_boxes' ), 1, 2 ); |
|
| 66 | + add_action('save_post', array($this, 'save_meta_boxes'), 1, 2); |
|
| 67 | 67 | |
| 68 | 68 | // Uncomment this for debugging $_POST while saving a meta box. |
| 69 | 69 | // add_action( 'save_post', function() { echo '<pre>'; print_r( $_POST ); echo '</pre>'; die(); } ); |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | add_meta_box( |
| 80 | 80 | 'simcal-calendar-settings', |
| 81 | - __( 'Calendar Settings', 'google-calendar-events' ), |
|
| 81 | + __('Calendar Settings', 'google-calendar-events'), |
|
| 82 | 82 | '\SimpleCalendar\Admin\Metaboxes\Settings::html', |
| 83 | 83 | 'calendar', |
| 84 | 84 | 'normal', |
| 85 | 85 | 'core' |
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | - $addons = apply_filters( 'simcal_installed_addons', array() ); |
|
| 89 | - if ( empty( $addons ) ) { |
|
| 88 | + $addons = apply_filters('simcal_installed_addons', array()); |
|
| 89 | + if (empty($addons)) { |
|
| 90 | 90 | |
| 91 | 91 | add_meta_box( |
| 92 | 92 | 'simcal-newsletter', |
| 93 | - __( 'Get 20% off all Pro Add-ons', 'google-calendar-events' ), |
|
| 93 | + __('Get 20% off all Pro Add-ons', 'google-calendar-events'), |
|
| 94 | 94 | '\SimpleCalendar\Admin\Metaboxes\Newsletter::html', |
| 95 | 95 | 'calendar', |
| 96 | 96 | 'side', |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | add_meta_box( |
| 103 | 103 | 'simcal-get-shortcode', |
| 104 | - __( 'Calendar Shortcode', 'google-calendar-events' ), |
|
| 104 | + __('Calendar Shortcode', 'google-calendar-events'), |
|
| 105 | 105 | '\SimpleCalendar\Admin\Metaboxes\Get_Shortcode::html', |
| 106 | 106 | 'calendar', |
| 107 | 107 | 'side', |
@@ -109,11 +109,11 @@ discard block |
||
| 109 | 109 | ); |
| 110 | 110 | |
| 111 | 111 | // Add meta box if there are calendars. |
| 112 | - if ( ( true == simcal_get_calendars() ) && ! empty( $this->post_types ) ) { |
|
| 113 | - foreach ( $this->post_types as $post_type ) { |
|
| 112 | + if ((true == simcal_get_calendars()) && ! empty($this->post_types)) { |
|
| 113 | + foreach ($this->post_types as $post_type) { |
|
| 114 | 114 | add_meta_box( |
| 115 | 115 | 'simcal-attach-calendar', |
| 116 | - __( 'Attach Calendar', 'google-calendar-events' ), |
|
| 116 | + __('Attach Calendar', 'google-calendar-events'), |
|
| 117 | 117 | '\SimpleCalendar\Admin\Metaboxes\Attach_Calendar::html', |
| 118 | 118 | $post_type, |
| 119 | 119 | 'side', |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - do_action( 'simcal_add_meta_boxes' ); |
|
| 125 | + do_action('simcal_add_meta_boxes'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -135,30 +135,30 @@ discard block |
||
| 135 | 135 | * |
| 136 | 136 | * @return void |
| 137 | 137 | */ |
| 138 | - public function save_meta_boxes( $post_id, $post ) { |
|
| 138 | + public function save_meta_boxes($post_id, $post) { |
|
| 139 | 139 | |
| 140 | 140 | // $post_id and $post are required. |
| 141 | - if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) { |
|
| 141 | + if (empty($post_id) || empty($post) || self::$saved_meta_boxes) { |
|
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | // Don't save meta boxes for revisions or autosaves. |
| 146 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
| 146 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
| 147 | 147 | return; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | // Check the nonce. |
| 151 | - if ( empty( $_POST['simcal_meta_nonce'] ) || ! wp_verify_nonce( $_POST['simcal_meta_nonce'], 'simcal_save_data' ) ) { |
|
| 151 | + if (empty($_POST['simcal_meta_nonce']) || ! wp_verify_nonce($_POST['simcal_meta_nonce'], 'simcal_save_data')) { |
|
| 152 | 152 | return; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
| 156 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
| 156 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
| 157 | 157 | return; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Check user has permission to edit |
| 161 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 161 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
| 162 | 162 | return; |
| 163 | 163 | } |
| 164 | 164 | |
@@ -171,13 +171,13 @@ discard block |
||
| 171 | 171 | self::$saved_meta_boxes = true; |
| 172 | 172 | |
| 173 | 173 | // Check the post type. |
| 174 | - if ( 'calendar' == $post->post_type ) { |
|
| 175 | - do_action( 'simcal_save_settings_meta', $post_id, $post ); |
|
| 176 | - } elseif ( in_array( $post->post_type, $this->post_types ) ) { |
|
| 177 | - do_action( 'simcal_save_attach_calendar_meta', $post_id, $post ); |
|
| 174 | + if ('calendar' == $post->post_type) { |
|
| 175 | + do_action('simcal_save_settings_meta', $post_id, $post); |
|
| 176 | + } elseif (in_array($post->post_type, $this->post_types)) { |
|
| 177 | + do_action('simcal_save_attach_calendar_meta', $post_id, $post); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - do_action( 'simcal_save_meta_boxes', $post_id, $post ); |
|
| 180 | + do_action('simcal_save_meta_boxes', $post_id, $post); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Field; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; |
| 13 | 13 | } |
| 14 | 14 | |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @param array $field |
| 36 | 36 | */ |
| 37 | - public function __construct( $field ) { |
|
| 38 | - $this->addon = isset( $field['addon'] ) ? esc_attr( $field['addon'] ) : ''; |
|
| 37 | + public function __construct($field) { |
|
| 38 | + $this->addon = isset($field['addon']) ? esc_attr($field['addon']) : ''; |
|
| 39 | 39 | $this->type_class = 'simcal-field-license'; |
| 40 | - parent::__construct( $field ); |
|
| 40 | + parent::__construct($field); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | public function html() { |
| 49 | 49 | |
| 50 | - if ( ! empty( $this->addon ) ) { |
|
| 50 | + if ( ! empty($this->addon)) { |
|
| 51 | 51 | |
| 52 | - $status = apply_filters( 'simcal_addon_status_' . $this->addon, simcal_get_license_status( $this->addon ) ); |
|
| 52 | + $status = apply_filters('simcal_addon_status_'.$this->addon, simcal_get_license_status($this->addon)); |
|
| 53 | 53 | |
| 54 | - if ( $status !== 'valid' ) { |
|
| 54 | + if ($status !== 'valid') { |
|
| 55 | 55 | $display_activate = 'display: inline-block'; |
| 56 | 56 | $display_deactivate = 'display: none'; |
| 57 | 57 | $active = 'valid' == $status ? 'display: block' : 'display: none'; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | } else { |
| 60 | 60 | $display_activate = $active = 'display: none'; |
| 61 | 61 | $display_deactivate = 'display: inline-block'; |
| 62 | - $disabled = empty( $this->value ) ? '' : 'disabled="disabled"'; |
|
| 62 | + $disabled = empty($this->value) ? '' : 'disabled="disabled"'; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | ?> |
@@ -74,16 +74,16 @@ discard block |
||
| 74 | 74 | <span class="simcal-addon-manage-license-buttons"> |
| 75 | 75 | |
| 76 | 76 | <button class="button-secondary simcal-addon-manage-license deactivate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_deactivate; ?>"> |
| 77 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Deactivate', 'google-calendar-events' ); ?> |
|
| 77 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Deactivate', 'google-calendar-events'); ?> |
|
| 78 | 78 | </button> |
| 79 | 79 | |
| 80 | 80 | <button class="button-secondary simcal-addon-manage-license activate" data-add-on="<?php echo $this->addon; ?>" style="<?php echo $display_activate; ?>"> |
| 81 | - <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e( 'Activate', 'google-calendar-events' ); ?> |
|
| 81 | + <i class="simcal-icon-spinner simcal-icon-spin" style="display: none;"></i><?php _e('Activate', 'google-calendar-events'); ?> |
|
| 82 | 82 | </button> |
| 83 | 83 | |
| 84 | 84 | <span class="error" style="color: red; display: none"> </span> |
| 85 | 85 | |
| 86 | - <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e( '(active)', 'google-calendar-events' ); ?></strong> |
|
| 86 | + <strong class="label" style="color:green; <?php echo $active; ?>"> <?php _e('(active)', 'google-calendar-events'); ?></strong> |
|
| 87 | 87 | |
| 88 | 88 | </span> |
| 89 | 89 | |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | use SimpleCalendar\Abstracts\Field; |
| 10 | 10 | |
| 11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | +if ( ! defined('ABSPATH')) { |
|
| 12 | 12 | exit; // Exit if accessed directly. |
| 13 | 13 | } |
| 14 | 14 | |
@@ -28,9 +28,9 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @param array $field |
| 30 | 30 | */ |
| 31 | - public function __construct( $field ) { |
|
| 31 | + public function __construct($field) { |
|
| 32 | 32 | $this->type_class = 'simcal-field-checkboxes'; |
| 33 | - parent::__construct( $field ); |
|
| 33 | + parent::__construct($field); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
@@ -40,33 +40,33 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | public function html() { |
| 42 | 42 | |
| 43 | - if ( ! empty( $this->options ) && count( (array) $this->options ) > 1 ) { |
|
| 43 | + if ( ! empty($this->options) && count((array) $this->options) > 1) { |
|
| 44 | 44 | |
| 45 | - if ( ! empty( $this->description ) ) { |
|
| 46 | - echo '<p class="description">' . wp_kses_post( $this->description ) . ' ' . $this->tooltip . '</p>'; |
|
| 45 | + if ( ! empty($this->description)) { |
|
| 46 | + echo '<p class="description">'.wp_kses_post($this->description).' '.$this->tooltip.'</p>'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | ?> |
| 50 | - <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty( $this->style ) ? 'style="' . $this->style . '"' : ''; ?>> |
|
| 50 | + <fieldset class="<?php echo $this->class; ?>" <?php echo ! empty($this->style) ? 'style="'.$this->style.'"' : ''; ?>> |
|
| 51 | 51 | <?php |
| 52 | 52 | |
| 53 | - if ( ! empty( $this->title ) ) { |
|
| 54 | - echo '<legend class="screen-reader-text"><span>' . $this->title . '</span></legend>'; |
|
| 53 | + if ( ! empty($this->title)) { |
|
| 54 | + echo '<legend class="screen-reader-text"><span>'.$this->title.'</span></legend>'; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | ?> |
| 58 | 58 | <ul> |
| 59 | - <?php foreach ( $this->options as $option => $name ) : ?> |
|
| 59 | + <?php foreach ($this->options as $option => $name) : ?> |
|
| 60 | 60 | <li> |
| 61 | - <label for="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>"> |
|
| 61 | + <label for="<?php echo $this->id.'-'.trim(strval($option)); ?>"> |
|
| 62 | 62 | <input name="<?php echo $this->name; ?>" |
| 63 | - id="<?php echo $this->id . '-' . trim( strval( $option ) ); ?>" |
|
| 63 | + id="<?php echo $this->id.'-'.trim(strval($option)); ?>" |
|
| 64 | 64 | class="simcal-field simcal-field-checkbox" |
| 65 | 65 | type="checkbox" |
| 66 | - value="<?php echo trim( strval( $option ) ); ?>" |
|
| 67 | - <?php checked( $this->value, 'yes', true ); ?> |
|
| 66 | + value="<?php echo trim(strval($option)); ?>" |
|
| 67 | + <?php checked($this->value, 'yes', true); ?> |
|
| 68 | 68 | <?php echo $this->attributes; ?> |
| 69 | - /><?php echo esc_attr( $name ); ?> |
|
| 69 | + /><?php echo esc_attr($name); ?> |
|
| 70 | 70 | </label> |
| 71 | 71 | </li> |
| 72 | 72 | <?php endforeach; ?> |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | } else { |
| 78 | 78 | |
| 79 | 79 | ?> |
| 80 | - <span class="simcal-field-bool" <?php echo $this->style ? 'style="' . $this->style . '"' : ''; ?>> |
|
| 81 | - <?php if ( ! empty( $this->title ) ) : ?> |
|
| 80 | + <span class="simcal-field-bool" <?php echo $this->style ? 'style="'.$this->style.'"' : ''; ?>> |
|
| 81 | + <?php if ( ! empty($this->title)) : ?> |
|
| 82 | 82 | <span class="screen-reader-text"><?php echo $this->title; ?></span> |
| 83 | 83 | <?php endif; ?> |
| 84 | 84 | <input name="<?php echo $this->name; ?>" |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | id="<?php echo $this->id; ?>" |
| 87 | 87 | class="simcal-field simcal-field-checkbox <?php echo $this->class; ?>" |
| 88 | 88 | value="yes" |
| 89 | - <?php checked( $this->value, 'yes', true ); ?> |
|
| 90 | - <?php echo $this->attributes; ?>/><?php echo ( ! empty( $this->text ) ? $this->text : __( 'Yes', 'google-calendar-events' ) ); ?> |
|
| 89 | + <?php checked($this->value, 'yes', true); ?> |
|
| 90 | + <?php echo $this->attributes; ?>/><?php echo ( ! empty($this->text) ? $this->text : __('Yes', 'google-calendar-events')); ?> |
|
| 91 | 91 | </span> |
| 92 | 92 | <?php |
| 93 | 93 | |
| 94 | 94 | echo $this->tooltip; |
| 95 | 95 | |
| 96 | - if ( ! empty( $this->description ) ) { |
|
| 97 | - echo '<p class="description">' . wp_kses_post( $this->description ) . '</p>'; |
|
| 96 | + if ( ! empty($this->description)) { |
|
| 97 | + echo '<p class="description">'.wp_kses_post($this->description).'</p>'; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | } |
@@ -143,7 +143,7 @@ |
||
| 143 | 143 | |
| 144 | 144 | $links = array(); |
| 145 | 145 | $links['add-ons'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . |
| 146 | - __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
| 146 | + __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
| 147 | 147 | |
| 148 | 148 | return apply_filters( 'simcal_plugin_action_links', array_merge( $meta_links, $links ) ); |
| 149 | 149 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | */ |
| 7 | 7 | namespace SimpleCalendar\Admin; |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if ( ! defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -44,17 +44,17 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | self::$main_menu = 'edit.php?post_type=calendar'; |
| 46 | 46 | |
| 47 | - add_action( 'admin_menu', array( __CLASS__, 'add_menu_items' ) ); |
|
| 47 | + add_action('admin_menu', array(__CLASS__, 'add_menu_items')); |
|
| 48 | 48 | |
| 49 | - self::$plugin = plugin_basename( SIMPLE_CALENDAR_MAIN_FILE ); |
|
| 49 | + self::$plugin = plugin_basename(SIMPLE_CALENDAR_MAIN_FILE); |
|
| 50 | 50 | |
| 51 | 51 | new Welcome(); |
| 52 | 52 | |
| 53 | 53 | // Links and meta content in plugins page. |
| 54 | - add_filter( 'plugin_action_links_' . self::$plugin, array( __CLASS__, 'plugin_action_links' ), 10, 5 ); |
|
| 55 | - add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 ); |
|
| 54 | + add_filter('plugin_action_links_'.self::$plugin, array(__CLASS__, 'plugin_action_links'), 10, 5); |
|
| 55 | + add_filter('plugin_row_meta', array(__CLASS__, 'plugin_row_meta'), 10, 2); |
|
| 56 | 56 | // Custom text in admin footer. |
| 57 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1 ); |
|
| 57 | + add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -66,41 +66,41 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | add_submenu_page( |
| 68 | 68 | self::$main_menu, |
| 69 | - __( 'Settings', 'google-calendar-events' ), |
|
| 70 | - __( 'Settings', 'google-calendar-events' ), |
|
| 69 | + __('Settings', 'google-calendar-events'), |
|
| 70 | + __('Settings', 'google-calendar-events'), |
|
| 71 | 71 | 'manage_options', |
| 72 | 72 | 'simple-calendar_settings', |
| 73 | - function () { |
|
| 74 | - $page = new Pages( 'settings' ); |
|
| 73 | + function() { |
|
| 74 | + $page = new Pages('settings'); |
|
| 75 | 75 | $page->html(); |
| 76 | 76 | } |
| 77 | 77 | ); |
| 78 | 78 | |
| 79 | 79 | add_submenu_page( |
| 80 | 80 | self::$main_menu, |
| 81 | - __( 'Add-ons', 'google-calendar-events' ), |
|
| 82 | - __( 'Add-ons', 'google-calendar-events' ), |
|
| 81 | + __('Add-ons', 'google-calendar-events'), |
|
| 82 | + __('Add-ons', 'google-calendar-events'), |
|
| 83 | 83 | 'manage_options', |
| 84 | 84 | 'simple-calendar_add_ons', |
| 85 | 85 | function() { |
| 86 | - $page = new Pages( 'add-ons' ); |
|
| 86 | + $page = new Pages('add-ons'); |
|
| 87 | 87 | $page->html(); |
| 88 | 88 | } |
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | 91 | add_submenu_page( |
| 92 | 92 | self::$main_menu, |
| 93 | - __( 'Tools', 'google-calendar-events' ), |
|
| 94 | - __( 'Tools', 'google-calendar-events' ), |
|
| 93 | + __('Tools', 'google-calendar-events'), |
|
| 94 | + __('Tools', 'google-calendar-events'), |
|
| 95 | 95 | 'manage_options', |
| 96 | 96 | 'simple-calendar_tools', |
| 97 | - function () { |
|
| 98 | - $page = new Pages( 'tools' ); |
|
| 97 | + function() { |
|
| 98 | + $page = new Pages('tools'); |
|
| 99 | 99 | $page->html(); |
| 100 | 100 | } |
| 101 | 101 | ); |
| 102 | 102 | |
| 103 | - do_action( 'simcal_admin_add_menu_items' ); |
|
| 103 | + do_action('simcal_admin_add_menu_items'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return array |
| 115 | 115 | */ |
| 116 | - public static function plugin_action_links( $action_links, $file ) { |
|
| 116 | + public static function plugin_action_links($action_links, $file) { |
|
| 117 | 117 | |
| 118 | - if ( self::$plugin == $file ) { |
|
| 118 | + if (self::$plugin == $file) { |
|
| 119 | 119 | |
| 120 | 120 | $links = array(); |
| 121 | - $links['settings'] = '<a href="' . admin_url( 'edit.php?post_type=calendar&page=simple-calendar_settings' ) . '">' . __( 'Settings', 'google-calendar-events' ) . '</a>'; |
|
| 122 | - $links['feeds'] = '<a href="' . admin_url( 'edit.php?post_type=calendar' ) . '">' . __( 'Calendars', 'google-calendar-events' ) . '</a>'; |
|
| 121 | + $links['settings'] = '<a href="'.admin_url('edit.php?post_type=calendar&page=simple-calendar_settings').'">'.__('Settings', 'google-calendar-events').'</a>'; |
|
| 122 | + $links['feeds'] = '<a href="'.admin_url('edit.php?post_type=calendar').'">'.__('Calendars', 'google-calendar-events').'</a>'; |
|
| 123 | 123 | |
| 124 | - return apply_filters( 'simcal_plugin_action_links', array_merge( $links, $action_links ) ); |
|
| 124 | + return apply_filters('simcal_plugin_action_links', array_merge($links, $action_links)); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return $action_links; |
@@ -137,15 +137,15 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @return array |
| 139 | 139 | */ |
| 140 | - public static function plugin_row_meta( $meta_links, $file ) { |
|
| 140 | + public static function plugin_row_meta($meta_links, $file) { |
|
| 141 | 141 | |
| 142 | - if ( self::$plugin == $file ) { |
|
| 142 | + if (self::$plugin == $file) { |
|
| 143 | 143 | |
| 144 | 144 | $links = array(); |
| 145 | - $links['add-ons'] = '<a href="' . simcal_ga_campaign_url( simcal_get_url( 'addons' ), 'core-plugin', 'plugin-listing' ) . '" target="_blank" >' . |
|
| 146 | - __( 'Add-ons', 'google-calendar-events' ) . '</a>'; |
|
| 145 | + $links['add-ons'] = '<a href="'.simcal_ga_campaign_url(simcal_get_url('addons'), 'core-plugin', 'plugin-listing').'" target="_blank" >'. |
|
| 146 | + __('Add-ons', 'google-calendar-events').'</a>'; |
|
| 147 | 147 | |
| 148 | - return apply_filters( 'simcal_plugin_action_links', array_merge( $meta_links, $links ) ); |
|
| 148 | + return apply_filters('simcal_plugin_action_links', array_merge($meta_links, $links)); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | return $meta_links; |
@@ -162,13 +162,13 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @return string|void |
| 164 | 164 | */ |
| 165 | - public function admin_footer_text( $footer_text ) { |
|
| 165 | + public function admin_footer_text($footer_text) { |
|
| 166 | 166 | |
| 167 | 167 | // Check to make sure we're on a SimpleCal admin page |
| 168 | 168 | $screen = simcal_is_admin_screen(); |
| 169 | - if ( $screen !== false ) { |
|
| 169 | + if ($screen !== false) { |
|
| 170 | 170 | |
| 171 | - if ( 'calendar' == $screen ) { |
|
| 171 | + if ('calendar' == $screen) { |
|
| 172 | 172 | |
| 173 | 173 | // Add Drip promo signup form (@see Newsletter meta box). |
| 174 | 174 | |
@@ -196,23 +196,23 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | // Change the footer text |
| 199 | - if ( ! get_option( 'simple-calendar_admin_footer_text_rated' ) ) { |
|
| 199 | + if ( ! get_option('simple-calendar_admin_footer_text_rated')) { |
|
| 200 | 200 | |
| 201 | 201 | $footer_text = sprintf( |
| 202 | - __( 'If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events' ), |
|
| 203 | - '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'google-calendar-events' ) . '">', '</a>' |
|
| 202 | + __('If you like <strong>Simple Calendar</strong> please leave us a %s★★★★★ rating on WordPress.org%s. A huge thank you in advance!', 'google-calendar-events'), |
|
| 203 | + '<a href="https://wordpress.org/support/view/plugin-reviews/google-calendar-events?filter=5#postform" target="_blank" class="simcal-rating-link" data-rated="'.esc_attr__('Thanks :)', 'google-calendar-events').'">', '</a>' |
|
| 204 | 204 | ); |
| 205 | 205 | |
| 206 | 206 | $footer_text .= '<script type="text/javascript">'; |
| 207 | 207 | $footer_text .= "jQuery( 'a.simcal-rating-link' ).click( function() { |
| 208 | - jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url() . "', { action: 'simcal_rated' } ); |
|
| 208 | + jQuery.post( '" . \SimpleCalendar\plugin()->ajax_url()."', { action: 'simcal_rated' } ); |
|
| 209 | 209 | jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) ); |
| 210 | 210 | });"; |
| 211 | 211 | $footer_text .= '</script>'; |
| 212 | 212 | |
| 213 | 213 | } else { |
| 214 | 214 | |
| 215 | - $footer_text = __( 'Thanks for using Simple Calendar!', 'google-calendar-events' ); |
|
| 215 | + $footer_text = __('Thanks for using Simple Calendar!', 'google-calendar-events'); |
|
| 216 | 216 | |
| 217 | 217 | } |
| 218 | 218 | |