Changeset 1060499
- Timestamp:
- 01/05/2015 03:35:13 PM (11 years ago)
- Location:
- osd-outdated-browser
- Files:
-
- 11 added
- 4 edited
-
tags/1.4 (added)
-
tags/1.4/img (added)
-
tags/1.4/img/chrome.png (added)
-
tags/1.4/img/firefox.png (added)
-
tags/1.4/osd_outdated_browser.php (added)
-
tags/1.4/osd_outdated_browser_options.php (added)
-
tags/1.4/osd_outdated_browser_widget.php (added)
-
tags/1.4/readme.txt (added)
-
tags/1.4/script.js (added)
-
tags/1.4/style.css (added)
-
trunk/osd_outdated_browser.php (modified) (7 diffs)
-
trunk/osd_outdated_browser_options.php (modified) (1 diff)
-
trunk/osd_outdated_browser_widget.php (added)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/style.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
osd-outdated-browser/trunk/osd_outdated_browser.php
r1002588 r1060499 4 4 * Plugin URI: http://outsidesource.com 5 5 * Description: Notifies users that they are using an outdated browser. 6 * Version: 1. 36 * Version: 1.4 7 7 * Author: OSD Web Development Team 8 8 * Author URI: http://outsidesource.com … … 11 11 12 12 13 /** 14 * Widget class for notifying users that they are using an outdated browser 15 * ---------------------------------------------------------------------------- 16 */ 17 18 class OSD_Outdated_Browser extends WP_Widget { 19 // Widget Constructor 20 public function __construct() { 21 parent::__construct( 22 'osd_outdated_browser_widget', 23 'OSD Outdated Browser', 24 array('description' => __('Add a banner for outdated browsers.')) 25 ); 26 13 // Core OSD Outdated Browser class 14 class OSD_Outdated_Browser { 15 // Constructor 16 function __construct() { 27 17 // Set options 28 18 $this->options = get_option('osd_outdated_browser_options'); … … 32 22 if ($this->check_show_popup()) { 33 23 add_action('wp_head', array($this, 'osd_outdated_browser_style')); 34 add_action('wp_footer', array($this, 'osd_outdated_browser_script')); 24 add_action('wp_footer', array($this, 'osd_outdated_browser_script')); 35 25 } 26 27 // Add shortcode 28 add_shortcode("osd_outdated_browser", array($this, "output_html")); 36 29 } 37 30 38 39 31 // Default variables 40 public static$defaults = array(32 public $defaults = array( 41 33 'browser' => 'none', 42 34 'bg-color' => '#ffffff', … … 53 45 <span class='osd-outdated-browser-close' id='osd-outdated-browser-close' style='text-decoration: underline; display: inline-block; margin: 5px 0;'>Close this window</span> 54 46 </p> 55 <p style='text-align: center;'>By closing this window you acknowledge that your experience on our website may be degraded.</p> 56 "); 47 <p style='text-align: center;'>By closing this window you acknowledge that your experience on our website may be degraded.</p>"); 57 48 58 49 59 50 // Returns true if the popup should be shown 60 privatefunction check_show_popup() {61 if ( !is_active_widget(false, false, "osd_outdated_browser_widget", true)) {51 function check_show_popup() { 52 if (isset($_COOKIE['osd_outdated_browser'])) { 62 53 return false; 63 } else if (isset($_COOKIE['osd_outdated_browser'])) { 64 return false; 65 } 66 $userAgent = $_SERVER['HTTP_USER_AGENT']; 67 if ($this->get_val('browser') == 'none') { 54 } else if ($this->get_val('browser') == 'none') { 68 55 return false; 69 56 } else if ($this->get_val('browser') == 'all') { 70 57 return true; 71 } else if (preg_match("/Trident\/.*rv:([0-9]{2,2})\.0/", $ userAgent, $match) ||72 preg_match("/MSIE\s([0-9]{1,2})\.0/", $ userAgent, $match)) {73 if (stripos($ userAgent, "opera") !== false) {58 } else if (preg_match("/Trident\/.*rv:([0-9]{2,2})\.0/", $_SERVER['HTTP_USER_AGENT'], $match) || 59 preg_match("/MSIE\s([0-9]{1,2})\.0/", $_SERVER['HTTP_USER_AGENT'], $match)) { 60 if (stripos($_SERVER['HTTP_USER_AGENT'], "opera") !== false) { 74 61 return false; 75 62 } else if ($match[1] <= $this->get_val('browser')) { … … 81 68 82 69 // Returns the default value if one is not set 83 privatefunction get_val($prop) {70 function get_val($prop) { 84 71 if ($prop == "message" && !$this->options[$prop]) { 85 OSD_Outdated_Browser::$defaults[$prop] = str_replace("###URL###", plugins_url(), OSD_Outdated_Browser::$defaults['message']);72 $this->defaults[$prop] = str_replace("###URL###", plugins_url(), $this->defaults['message']); 86 73 } 87 return ($this->options[$prop]) ? $this->options[$prop] : OSD_Outdated_Browser::$defaults[$prop];74 return ($this->options[$prop]) ? $this->options[$prop] : $this->defaults[$prop]; 88 75 } 89 76 90 77 91 // Outputs the content of the widget92 public function widget($args, $instance) {78 // Show the popup 79 function output_html() { 93 80 if ($this->check_show_popup()) { 94 $this->output_html($this->options); 81 $content = "<div id='osd-outdated-browser' class='osd-outdated-browser'>".apply_filters('the_content', $this->get_val('message'))."</div>"; 82 echo apply_filters('osd_outdated_browser', $content, $this->options); 95 83 } 96 }97 98 // Outputs the content of the widget99 private function output_html($options) {100 $content = "<div id='osd-outdated-browser' class='osd-outdated-browser'>".apply_filters('the_content', $this->get_val('message'))."</div>";101 echo apply_filters('osd_outdated_browser', $content, $options);102 }103 104 105 // Outputs the options form on admin106 public function form($instance) {107 echo "<p>Visit the settings page to customize this widget</p>";108 }109 110 111 // Processing widget options on save112 public function update($new_instance, $old_instance) {113 foreach ($new_instance as $key => $value) {114 $new_instance[$key] = strip_tags($new_instance[$key]);115 }116 return $new_instance;117 84 } 118 85 119 86 120 87 // Register OSD Outdated Browser Style 121 publicfunction osd_outdated_browser_style() {88 function osd_outdated_browser_style() { 122 89 $style = file_get_contents('style.css', true); 123 90 $style = str_replace("##BG-COLOR##", $this->get_val('bg-color'), $style); … … 128 95 129 96 // Register OSD Outdated Browser Script 130 publicfunction osd_outdated_browser_script() {97 function osd_outdated_browser_script() { 131 98 $script = file_get_contents('script.js', true); 132 99 $script = str_replace("##COOKIE##", $this->get_val('cookie'), $script); … … 135 102 } 136 103 104 // Instantiate the instance 105 $osd_outdated_browser_instance = new OSD_Outdated_Browser(); 137 106 138 // Register OSD Outdated Browser Widget 139 function register_osd_outdated_browser_widget() { 140 register_widget('OSD_Outdated_Browser'); 141 } 142 add_action('widgets_init', 'register_osd_outdated_browser_widget'); 143 107 // Include widget 108 include_once('osd_outdated_browser_widget.php'); 144 109 145 110 // Include options 146 111 include_once('osd_outdated_browser_options.php'); 147 ?> -
osd-outdated-browser/trunk/osd_outdated_browser_options.php
r967661 r1060499 34 34 $options = get_option('osd_outdated_browser_options'); 35 35 $options['message'] = get_option('osd_outdated_browser_message'); 36 global $osd_outdated_browser_instance; 36 37 37 foreach ( OSD_Outdated_Browser::$defaults as $key => $value) {38 foreach ($osd_outdated_browser_instance->defaults as $key => $value) { 38 39 if ($key == "message") { 39 $value = str_replace("###URL###", plugins_url(), OSD_Outdated_Browser::$defaults['message']);40 $value = str_replace("###URL###", plugins_url(), $osd_outdated_browser_instance->defaults['message']); 40 41 } 41 42 $options[$key] = ($options[$key]) ? $options[$key] : $value; -
osd-outdated-browser/trunk/readme.txt
r1002565 r1060499 4 4 Requires at least: 3.4 5 5 Tested up to: 4.0 6 Stable tag: 1. 36 Stable tag: 1.4 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 12 12 == Description == 13 13 14 OSD Outdated Browser widget allows you to display a custom banner for users using old browsers. 14 OSD Outdated Browser widget allows you to display a custom banner for users using old browsers. 15 15 The banner is fully customizable and also exposes filters for developers to use. All a user needs to do 16 16 is install/activate the plugin, set up the proper settings, then add the OSD Outdated Browser widget … … 41 41 42 42 == Changelog == 43 44 = 1.4 = 45 * Fixed minor styling bug 46 * Enabled use with a shortcode 43 47 44 48 = 1.3 = -
osd-outdated-browser/trunk/style.css
r982152 r1060499 1 1 /* Styles for OSD Outdated Browser */ 2 .osd-outdated-browser { position: fixed; width: 100%; top: 0; padding: 20px; z-index: 1000; font-family: Helvetica, Sans-serif; font-size: 13px; color: ##FONT-COLOR##; background: ##BG-COLOR##; box-shadow: 0px 0px 10px rgba(0,0,0,.5); }2 .osd-outdated-browser { position: fixed; width: 100%; left: 0; top: 0; padding: 20px; z-index: 1000; font-family: Helvetica, Sans-serif; font-size: 13px; color: ##FONT-COLOR##; background: ##BG-COLOR##; box-shadow: 0px 0px 10px rgba(0,0,0,.5); } 3 3 .osd-outdated-browser img { outline: none; border: 0; } 4 4 .osd-outdated-browser-images { margin-top: 5px; }
Note: See TracChangeset
for help on using the changeset viewer.