Plugin Directory

Changeset 1060499


Ignore:
Timestamp:
01/05/2015 03:35:13 PM (11 years ago)
Author:
osdwebdev
Message:

1.4 Release

Location:
osd-outdated-browser
Files:
11 added
4 edited

Legend:

Unmodified
Added
Removed
  • osd-outdated-browser/trunk/osd_outdated_browser.php

    r1002588 r1060499  
    44 * Plugin URI: http://outsidesource.com
    55 * Description: Notifies users that they are using an outdated browser.
    6  * Version: 1.3
     6 * Version: 1.4
    77 * Author: OSD Web Development Team
    88 * Author URI: http://outsidesource.com
     
    1111
    1212
    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
     14class OSD_Outdated_Browser {
     15    // Constructor
     16    function __construct() {
    2717        // Set options
    2818        $this->options = get_option('osd_outdated_browser_options');
     
    3222        if ($this->check_show_popup()) {
    3323            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'));
    3525        }
     26
     27        // Add shortcode
     28        add_shortcode("osd_outdated_browser", array($this, "output_html"));
    3629    }
    3730
    38 
    3931    // Default variables
    40     public static $defaults = array(
     32    public $defaults = array(
    4133        'browser' => 'none',
    4234        'bg-color' => '#ffffff',
     
    5345                <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>
    5446            </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>");
    5748
    5849
    5950    // Returns true if the popup should be shown
    60     private function 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'])) {
    6253            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') {
    6855            return false;
    6956        } else if ($this->get_val('browser') == 'all') {
    7057            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) {
    7461                return false;
    7562            } else if ($match[1] <= $this->get_val('browser')) {
     
    8168
    8269    // Returns the default value if one is not set
    83     private function get_val($prop) {
     70    function get_val($prop) {
    8471        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']);
    8673        }
    87         return ($this->options[$prop]) ? $this->options[$prop] : OSD_Outdated_Browser::$defaults[$prop];
     74        return ($this->options[$prop]) ? $this->options[$prop] : $this->defaults[$prop];
    8875    }
    8976
    9077
    91     // Outputs the content of the widget
    92     public function widget($args, $instance) {
     78    // Show the popup
     79    function output_html() {
    9380        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);
    9583        }
    96     }
    97 
    98     // Outputs the content of the widget
    99     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 admin
    106     public function form($instance) {
    107         echo "<p>Visit the settings page to customize this widget</p>";
    108     }
    109 
    110 
    111     // Processing widget options on save
    112     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;
    11784    }
    11885
    11986
    12087    // Register OSD Outdated Browser Style
    121     public function osd_outdated_browser_style() {
     88    function osd_outdated_browser_style() {
    12289        $style = file_get_contents('style.css', true);
    12390        $style = str_replace("##BG-COLOR##", $this->get_val('bg-color'), $style);
     
    12895
    12996    // Register OSD Outdated Browser Script
    130     public function osd_outdated_browser_script() {
     97    function osd_outdated_browser_script() {
    13198        $script = file_get_contents('script.js', true);
    13299        $script = str_replace("##COOKIE##", $this->get_val('cookie'), $script);
     
    135102}
    136103
     104// Instantiate the instance
     105$osd_outdated_browser_instance = new OSD_Outdated_Browser();
    137106
    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
     108include_once('osd_outdated_browser_widget.php');
    144109
    145110// Include options
    146111include_once('osd_outdated_browser_options.php');
    147 ?>
  • osd-outdated-browser/trunk/osd_outdated_browser_options.php

    r967661 r1060499  
    3434            $options = get_option('osd_outdated_browser_options');
    3535            $options['message'] = get_option('osd_outdated_browser_message');
     36            global $osd_outdated_browser_instance;
    3637
    37             foreach (OSD_Outdated_Browser::$defaults as $key => $value) {
     38            foreach ($osd_outdated_browser_instance->defaults as $key => $value) {
    3839                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']);
    4041                }
    4142                $options[$key] = ($options[$key]) ? $options[$key] : $value;
  • osd-outdated-browser/trunk/readme.txt

    r1002565 r1060499  
    44Requires at least: 3.4
    55Tested up to: 4.0
    6 Stable tag: 1.3
     6Stable tag: 1.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1212== Description ==
    1313
    14 OSD Outdated Browser widget allows you to display a custom banner for users using old browsers.
     14OSD Outdated Browser widget allows you to display a custom banner for users using old browsers. 
    1515The banner is fully customizable and also exposes filters for developers to use. All a user needs to do
    1616is install/activate the plugin, set up the proper settings, then add the OSD Outdated Browser widget
     
    4141
    4242== Changelog ==
     43
     44= 1.4 =
     45* Fixed minor styling bug
     46* Enabled use with a shortcode
    4347
    4448= 1.3 =
  • osd-outdated-browser/trunk/style.css

    r982152 r1060499  
    11/* 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); }
    33.osd-outdated-browser img { outline: none; border: 0; }
    44.osd-outdated-browser-images { margin-top: 5px; }
Note: See TracChangeset for help on using the changeset viewer.