Plugin Directory

Changeset 2964791


Ignore:
Timestamp:
09/09/2023 03:15:27 PM (3 years ago)
Author:
thangnv27
Message:

Release version 0.1.8

Location:
wp-multitasking/trunk
Files:
47 added
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • wp-multitasking/trunk/includes/bbcode.php

    r2323405 r2964791  
    66 */
    77class WPMT_BBCode {
     8    static $_s = null;
    89
    910    // Plugin initialization
     
    5051    }
    5152
     53    public static function init() {
     54        if (self::$_s == null) {
     55            self::$_s = new self();
     56        }
     57        return self::$_s;
     58    }
     59
    5260    // No-name attribute fixing
    5361    function attributefix($atts = array()) {
     
    238246
    239247// Start this plugin once all other plugins are fully loaded
    240 add_action('plugins_loaded', create_function('', 'global $WPMT_BBCode; $WPMT_BBCode = new WPMT_BBCode();'));
     248add_action( 'plugins_loaded', array( 'WPMT_BBCode', 'init' ) );
  • wp-multitasking/trunk/includes/floating-popup/exit-popup.php

    r2323405 r2964791  
    507507}
    508508function wpmt_exit_add_vars(){
     509    $popup_type = get_option('wpmt_popup_type');
     510    $popup_type = ($popup_type != 'fancybox') ? 'colorbox' : $popup_type;
    509511    $exit_popup_home = intval(get_option('exit_popup_home'));
    510512    $exit_pop_days = intval(get_option('default_exit_pop_days'));
     
    544546            echo <<<HTML
    545547<script type="text/javascript">
     548    var exit_popup_type = '$popup_type';
    546549    var exit_popup_cookieName = '$exit_popup_cookieName';
    547550    var exit_popup_days = $exit_pop_days;
     
    556559HTML;
    557560        }
    558     } else if (is_home()){
     561    } else if (is_home() or is_front_page()){
    559562        if($exit_popup_home == 1){
    560563            $exit_popup_cookieName = "exit_popup_home";
    561564            echo <<<HTML
    562565<script type="text/javascript">
     566    var exit_popup_type = '$popup_type';
    563567    var exit_popup_cookieName = '$exit_popup_cookieName';
    564568    var exit_popup_days = $exit_pop_days;
  • wp-multitasking/trunk/includes/floating-popup/global-popup.php

    r2323405 r2964791  
    88function wpmt_popup_add_styles() {
    99    $WPMT_PLUGIN_URL = WPMT_PLUGIN_URL;
     10    $popup_type = get_option('wpmt_popup_type');
     11    $colorbox_type = intval(get_option('wpmt_colorbox_type'));
     12    $colorbox_type = (!in_array($colorbox_type, [1,2,3,4,5])) ? 3 : $colorbox_type;
    1013
    1114    if (is_single() or is_page()) {
     
    1417        $welcome_active = get_post_meta($post_id, 'wcome_active', true);
    1518        if ($exit_active == 1 or $welcome_active == 1) {
    16             echo <<<HTML
    17 <link rel="stylesheet" type="text/css" media="screen" href="{$WPMT_PLUGIN_URL}libraries/colorbox/colorbox.css" />
     19            if ($popup_type != "fancybox") {
     20                echo <<<HTML
     21<link rel="stylesheet" type="text/css" media="screen" href="{$WPMT_PLUGIN_URL}libraries/colorbox/example{$colorbox_type}/colorbox.css?ver=1.6.4" />
    1822HTML;
     23            } else {
     24                echo <<<HTML
     25<link rel="stylesheet" type="text/css" media="screen" href="{$WPMT_PLUGIN_URL}libraries/fancybox/jquery.fancybox.min.css?ver=3.2.10" />
     26HTML;
     27            }
    1928        }
    20     } else if (is_home()) {
     29    } else if (is_home() or is_front_page()) {
    2130        $exit_popup_home = intval(get_option('exit_popup_home'));
    2231        $welcome_popup_home = intval(get_option('welcome_popup_home'));
    2332        if ($exit_popup_home == 1 or $welcome_popup_home == 1) {
    24             echo <<<HTML
    25 <link rel="stylesheet" type="text/css" media="screen" href="{$WPMT_PLUGIN_URL}libraries/colorbox/colorbox.css" />
     33            if ($popup_type != "fancybox") {
     34                echo <<<HTML
     35<link rel="stylesheet" type="text/css" media="screen" href="{$WPMT_PLUGIN_URL}libraries/colorbox/example{$colorbox_type}/colorbox.css?ver=1.6.4" />
    2636HTML;
     37            } else {
     38                echo <<<HTML
     39<link rel="stylesheet" type="text/css" media="screen" href="{$WPMT_PLUGIN_URL}libraries/fancybox/jquery.fancybox.min.css?ver=3.2.10" />
     40HTML;
     41            }
    2742        }
    2843    }
    2944}
     45
    3046function wpmt_popup_add_scripts(){
     47    $popup_type = get_option('wpmt_popup_type');
    3148    if(is_single() or is_page()){
    3249        $exit_active = get_post_meta(get_the_ID(), 'exit_active', true);
    3350        if($exit_active == 1){
    34             wp_enqueue_script('jquery.colorbox.js', WPMT_PLUGIN_URL . 'libraries/colorbox/jquery.colorbox.js', array('jquery'), false, true);
    35             wp_enqueue_script('common.multitasking.js', WPMT_PLUGIN_URL . 'js/common.multitasking.js', array('jquery'), false, true);
    36             wp_enqueue_script('floating.popup.js', WPMT_PLUGIN_URL . 'js/floating.popup.js', array('jquery'), false, true);
     51            if ($popup_type != 'fancybox') {
     52                wp_enqueue_script('wpmt-colorbox', WPMT_PLUGIN_URL . 'libraries/colorbox/jquery.colorbox-min.js', array('jquery'), '1.6.4', true);
     53            } else {
     54                wp_enqueue_script('wpmt-fancybox', WPMT_PLUGIN_URL . 'libraries/fancybox/jquery.fancybox.min.js', array('jquery'), '3.2.10', true);
     55            }
     56            wp_enqueue_script('wpmt-common', WPMT_PLUGIN_URL . 'js/common.multitasking.js', array('jquery'), WPMT_VER, true);
     57            wp_enqueue_script('wpmt-floating-popup', WPMT_PLUGIN_URL . 'js/floating.popup.js', array('jquery'), WPMT_VER, true);
    3758        }
    38     }elseif (is_home()) {
     59    }elseif (is_home() or is_front_page()) {
    3960        $exit_popup_home = intval(get_option('exit_popup_home'));
    4061        $welcome_popup_home = intval(get_option('welcome_popup_home'));
    4162        if ($exit_popup_home == 1 or $welcome_popup_home == 1) {           
    42             wp_enqueue_script('jquery.colorbox.js', WPMT_PLUGIN_URL . 'libraries/colorbox/jquery.colorbox.js', array('jquery'), false, true);
    43             wp_enqueue_script('common.multitasking.js', WPMT_PLUGIN_URL . 'js/common.multitasking.js', array('jquery'), false, true);
    44             wp_enqueue_script('floating.popup.js', WPMT_PLUGIN_URL . 'js/floating.popup.js', array('jquery'), false, true);
     63            if ($popup_type != 'fancybox') {
     64                wp_enqueue_script('wpmt-colorbox', WPMT_PLUGIN_URL . 'libraries/colorbox/jquery.colorbox-min.js', array('jquery'), '1.6.4', true);
     65            } else {
     66                wp_enqueue_script('wpmt-fancybox', WPMT_PLUGIN_URL . 'libraries/fancybox/jquery.fancybox.min.js', array('jquery'), '3.2.10', true);
     67            }
     68            wp_enqueue_script('wpmt-common', WPMT_PLUGIN_URL . 'js/common.multitasking.js', array('jquery'), WPMT_VER, true);
     69            wp_enqueue_script('wpmt-floating-popup', WPMT_PLUGIN_URL . 'js/floating.popup.js', array('jquery'), WPMT_VER, true);
    4570        }
    4671    }
  • wp-multitasking/trunk/includes/floating-popup/welcome-popup.php

    r2323405 r2964791  
    520520}
    521521function wpmt_welcome_add_vars(){
     522    $popup_type = get_option('wpmt_popup_type');
     523    $popup_type = ($popup_type != 'fancybox') ? 'colorbox' : $popup_type;
    522524    $welcome_popup_home = intval(get_option('welcome_popup_home'));
    523525    $wcome_pop_days = intval(get_option('default_wcome_pop_days'));
     
    559561            echo <<<HTML
    560562<script type="text/javascript">
     563    var welcome_popup_type = '$popup_type';
    561564    var welcome_popup_cookieName = '$wcome_popup_cookieName';
    562565    var welcome_popup_days = $wcome_pop_days;
     
    572575HTML;
    573576        }
    574     } else if (is_home()){
     577    } else if (is_home() or is_front_page()){
    575578        if($welcome_popup_home == 1){
    576579            $wcome_popup_cookieName = "welcome_popup_home";
    577580            echo <<<HTML
    578581<script type="text/javascript">
     582    var welcome_popup_type = '$popup_type';
    579583    var welcome_popup_cookieName = '$wcome_popup_cookieName';
    580584    var welcome_popup_days = $wcome_pop_days;
  • wp-multitasking/trunk/includes/permalinks.php

    r837190 r2964791  
    3838                                    //To link our submenu to a custom post type page we must specify -
    3939                                    //edit.php?post_type=my_post_type
    40             __('Permalinks'), // Page title
     40            __('Permalinks Settings'), // Page title
    4141            __('Permalinks'), // Menu title
    4242            'manage_options', // Capability - see: http://codex.wordpress.org/Roles_and_Capabilities#Capabilities
     
    172172            }
    173173        }
    174         if($post->post_type == "product"){
    175             if (isset($_SESSION['user_id'])){
    176                 if(strpos($permalink, "?") !== FALSE){
    177                     $permalink .= "&ap_id=" . $_SESSION['user_id'];
    178                 }else{
    179                     $permalink .= "?ap_id=" . $_SESSION['user_id'];
    180                 }
     174        // affiliate id
     175        if (isset($_SESSION['user_id'])){
     176            if(strpos($permalink, "?") !== FALSE){
     177                $permalink .= "&ap_id=" . $_SESSION['user_id'];
     178            }else{
     179                $permalink .= "?ap_id=" . $_SESSION['user_id'];
    181180            }
    182181        }
  • wp-multitasking/trunk/js/common.multitasking.js

    r831023 r2964791  
    11var WPMTFunc = {
    2     setCookie:function(name, value, expires, path, domain, secure){
     2    setCookie: function(name, value, expires, path, domain, secure) {
    33        var today = new Date();
    44        today.setTime(today.getTime());
    55        var expires_date = new Date(today.getTime() + (expires));
    6 
    7         document.cookie = name + "=" + escape(value) +
    8         ((expires) ? ";expires=" + expires_date.toGMTString() : "") +
    9         ((path) ? ";path=" + path : "") +
    10         ((domain) ? ";domain=" + domain : "") +
    11         ((secure) ? ";secure" : "");
     6        document.cookie = name + "=" + escape(value) + ((expires) ? ";expires=" + expires_date.toGMTString() : "") + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ((secure) ? ";secure" : "");
    127    },
    13     getCookie:function(name){
    14         /*var re=new RegExp(Name+"=[^;]+", "i");
    15         if (document.cookie.match(re))
    16             return decodeURIComponent(document.cookie.match(re)[0].split("=")[1]);
    17         return null;*/
    18 
     8    getCookie: function(name) {
    199        var start = document.cookie.indexOf(name + "=");
    2010        var len = start + name.length + 1;
    21         if ((!start) &&
    22             (name != document.cookie.substring(0, name.length))) {
     11        if ((!start) && (name != document.cookie.substring(0, name.length))) {
    2312            return null;
    2413        }
     
    2817        return unescape(document.cookie.substring(len, end));
    2918    },
    30     deleteCookie:function(name, path, domain){
    31         if (this.getCookie(name))
    32             document.cookie = name + "=" +
    33             ((path) ? ";path=" + path : "") +
    34             ((domain) ? ";domain=" + domain : "") +
    35             ";expires=Mon, 11-November-1989 00:00:01 GMT";
     19    deleteCookie: function(name, path, domain) {
     20        WPMTFunc.setCookie(name, '', -1 * 60 * 60 * 1000 * 24 * 365, path, domain); //-365 days
    3621    },
    37     addEvent:function(obj, eventName, func){
    38         if (obj.attachEvent){
     22    addEvent: function(obj, eventName, func) {
     23        if (obj.attachEvent) {
    3924            obj.attachEvent("on" + eventName, func);
    40         }
    41         else if(obj.addEventListener){
     25        } else if (obj.addEventListener) {
    4226            obj.addEventListener(eventName, func, true);
    43         }
    44         else{
     27        } else {
    4528            obj["on" + eventName] = func;
    4629        }
     30    },
     31    saveLocalStorage: function(key, value, ttl) {
     32        const now = new Date();
     33
     34        // `item` is an object which contains the original value
     35        // as well as the time when it's supposed to expire
     36        // ttl is seconds, example: 3600 = 1h
     37        const item = {
     38            value: value,
     39            expiry: now.getTime() + ttl * 1000
     40        };
     41        localStorage.setItem(key, JSON.stringify(item));
     42    },
     43    getLocalStorage: function(key) {
     44        const itemStr = localStorage.getItem(key);
     45        // if the item doesn't exist, return null
     46        if (!itemStr) {
     47            return null;
     48        }
     49        const item = JSON.parse(itemStr);
     50        const now = new Date();
     51        // compare the expiry time of the item with the current time
     52        if (now.getTime() > item.expiry) {
     53            // If the item is expired, delete the item from storage
     54            // and return null
     55            localStorage.removeItem(key);
     56            return null;
     57        }
     58        return item.value;
     59    },
     60    removeLocalStorage: function(key) {
     61        localStorage.removeItem(key);
    4762    }
    4863};
  • wp-multitasking/trunk/js/floating.popup.js

    r831023 r2964791  
    22var WelcomePopup = {
    33    show: function($){
     4        var pixelRatio = window.devicePixelRatio || 1;
     5        if ( pixelRatio > 1.5 ) {
     6          welcome_popup_width  = welcome_popup_width  / pixelRatio;
     7          welcome_popup_height = welcome_popup_height / pixelRatio;
     8        }
    49        if(welcome_popup_embed == 0){
    510            $.ajax({
     
    1722                    }
    1823                    setTimeout(function(){
     24                        if (welcome_popup_type == 'fancybox') {
     25                          $.fancybox.open(`<div style="width:${welcome_popup_width}px;height:${welcome_popup_height}px">${response}</div>`, {
     26                            transitionDuration: welcome_popup_speed,
     27                            clickSlide: (welcome_popup_overlayClose) ? "close" : false,
     28                            clickOutside: (welcome_popup_overlayClose) ? "close" : false
     29                          });
     30                        } else {
     31                          $.colorbox({
     32                              html: response,
     33                              width: welcome_popup_width,
     34                              height: welcome_popup_height,
     35                              speed: welcome_popup_speed,
     36                              overlayClose: welcome_popup_overlayClose,
     37                              fixed: true
     38                          });
     39                        }
     40                    }, welcome_popup_delays * 1000);
     41                }, 
     42                error: function(MLHttpRequest, textStatus, errorThrown){},
     43                complete:function(){}
     44            });
     45        } else if(welcome_popup_embed == 1){
     46            setTimeout(function(){
     47              if (welcome_popup_type == 'fancybox') {
     48                if (welcome_popup_content.indexOf('watch?v=') !== -1) {
     49                  welcome_popup_content = welcome_popup_content.replace('watch?v=', 'embed/')
     50                }
     51                $.fancybox.open({
     52                  src  : welcome_popup_content,
     53                  type : 'iframe',
     54                  opts : {
     55                    transitionDuration: welcome_popup_speed,
     56                    clickSlide: (welcome_popup_overlayClose) ? "close" : false,
     57                    clickOutside: (welcome_popup_overlayClose) ? "close" : false
     58                  }
     59                });
     60              } else {
     61                $.colorbox({
     62                    iframe: true,
     63                    href: welcome_popup_content,
     64                    width: welcome_popup_width,
     65                    height: welcome_popup_height,
     66                    speed: welcome_popup_speed,
     67                    overlayClose: welcome_popup_overlayClose,
     68                    fixed: true
     69                });
     70              }
     71            }, welcome_popup_delays * 1000);
     72        } else if(welcome_popup_embed == 2){
     73            $.ajax({
     74                type: 'POST',
     75                url: welcome_popup_ajaxUrl,
     76                data: {
     77                    action: 'wpmt_get_welcome_popup_custom_content',
     78                    post_id: welcome_popup_content
     79                },
     80                dataType: 'html',
     81                cache: false,
     82                success: function(response, textStatus, XMLHttpRequest){
     83                    if(welcome_popup_delays > 0){
     84                        welcome_popup_delays = welcome_popup_delays - 1;
     85                    }
     86                    setTimeout(function(){
     87                      if (welcome_popup_type == 'fancybox') {
     88                        $.fancybox.open(`<div style="width:${welcome_popup_width}px;height:${welcome_popup_height}px">${response}</div>`, {
     89                          transitionDuration: welcome_popup_speed,
     90                          clickSlide: (welcome_popup_overlayClose) ? "close" : false,
     91                          clickOutside: (welcome_popup_overlayClose) ? "close" : false
     92                        });
     93                      } else {
    1994                        $.colorbox({
    2095                            html: response,
     
    25100                            fixed: true
    26101                        });
    27                     }, welcome_popup_delays * 1000);
    28                 }, 
    29                 error: function(MLHttpRequest, textStatus, errorThrown){},
    30                 complete:function(){}
    31             });
    32         } else if(welcome_popup_embed == 1){
    33             setTimeout(function(){
    34                 $.colorbox({
    35                     iframe: true,
    36                     href: welcome_popup_content,
    37                     width: welcome_popup_width,
    38                     height: welcome_popup_height,
    39                     speed: welcome_popup_speed,
    40                     overlayClose: welcome_popup_overlayClose,
    41                     fixed: true
    42                 });
    43             }, welcome_popup_delays * 1000);
    44         } else if(welcome_popup_embed == 2){
    45             $.ajax({
    46                 type: 'POST',
    47                 url: welcome_popup_ajaxUrl,
    48                 data: {
    49                     action: 'wpmt_get_welcome_popup_custom_content',
    50                     post_id: welcome_popup_content
    51                 },
    52                 dataType: 'html',
    53                 cache: false,
    54                 success: function(response, textStatus, XMLHttpRequest){
    55                     if(welcome_popup_delays > 0){
    56                         welcome_popup_delays = welcome_popup_delays - 1;
    57                     }
    58                     setTimeout(function(){   
    59                         $.colorbox({
    60                             html: response,
    61                             width: welcome_popup_width,
    62                             height: welcome_popup_height,
    63                             speed: welcome_popup_speed,
    64                             overlayClose: welcome_popup_overlayClose,
    65                             fixed: true
    66                         });
     102                      }
    67103                    }, welcome_popup_delays * 1000);
    68104                }, 
     
    111147    },
    112148    show: function($){
     149        var pixelRatio = window.devicePixelRatio || 1;
     150        if ( pixelRatio > 1.5 ) {
     151          exit_popup_width  = exit_popup_width  / pixelRatio;
     152          exit_popup_height = exit_popup_height / pixelRatio;
     153        }
    113154        if(exit_popup_embed == 1){
     155          if (exit_popup_type == 'fancybox') {
     156            if (exit_popup_content.indexOf('watch?v=') !== -1) {
     157              exit_popup_content = exit_popup_content.replace('watch?v=', 'embed/')
     158            }
     159            $.fancybox.open({
     160              src  : exit_popup_content,
     161              type : 'iframe',
     162              opts : {
     163                transitionDuration: exit_popup_speed,
     164                clickSlide: (exit_popup_overlayClose) ? "close" : false,
     165                clickOutside: (exit_popup_overlayClose) ? "close" : false
     166              }
     167            });
     168          } else {
    114169            $.colorbox({
    115170                iframe: true,
     
    121176                fixed: true
    122177            });
     178          }
    123179        } else if(exit_popup_embed == 0 || exit_popup_embed == 2){
    124180            if(exit_content != ""){
     181              if (exit_popup_type == 'fancybox') {
     182                $.fancybox.open(`<div style="width:${exit_popup_width}px;height:${exit_popup_height}px">${exit_content}</div>`, {
     183                  transitionDuration: exit_popup_speed,
     184                  clickSlide: (exit_popup_overlayClose) ? "close" : false,
     185                  clickOutside: (exit_popup_overlayClose) ? "close" : false
     186                });
     187              } else {
    125188                $.colorbox({
    126189                    html: exit_content,
     
    131194                    fixed: true
    132195                });
     196              }
    133197            }
    134198        }
     
    137201jQuery(function($){
    138202    $(window).load(function(){
     203        // Exit
     204        ExitPopup.setup($);
     205        $(document).mousemove(function(e) {
     206          if (e.pageY <= 10) {
     207            if (exit_popup_type == 'fancybox' && $('.fancybox-container').length === 0) {
     208              ExitPopup.show($);
     209            } else if($("#cboxOverlay").is(":hidden")) {
     210              ExitPopup.show($);
     211            }
     212          }
     213        });
     214
     215        // Welcome
    139216        WelcomePopup.show($);
    140217        if(!WPMTFunc.getCookie(welcome_popup_cookieName)){
    141             ExitPopup.setup($);
    142218            WPMTFunc.setCookie(welcome_popup_cookieName, welcome_popup_days, 1 * 24*60*60*1000, '/', '', '');
    143219        }else if(WPMTFunc.getCookie(welcome_popup_cookieName) != welcome_popup_days){
    144220            WPMTFunc.setCookie(welcome_popup_cookieName, welcome_popup_days, 1 * 24*60*60*1000, '/', '', '');
    145221        }
    146         $(document).mousemove(function(e) {
    147             if(e.pageY <= 10 && $("#cboxOverlay").is(":hidden")) {
    148                 ExitPopup.show($);
    149             }
    150         });
    151222    });
    152223});
  • wp-multitasking/trunk/libraries/colorbox/jquery.colorbox.js

    r831023 r2964791  
    11/*!
    2     jQuery Colorbox v1.4.10 - 2013-04-02
    3     (c) 2013 Jack Moore - jacklmoore.com/colorbox
    4     license: http://www.opensource.org/licenses/mit-license.php
     2    Colorbox 1.6.4
     3    license: MIT
     4    http://www.jacklmoore.com/colorbox
    55*/
    66(function ($, document, window) {
     
    99    // See http://jacklmoore.com/colorbox for details.
    1010    defaults = {
     11        // data sources
     12        html: false,
     13        photo: false,
     14        iframe: false,
     15        inline: false,
     16
     17        // behavior and appearance
    1118        transition: "elastic",
    1219        speed: 300,
     20        fadeOut: 300,
    1321        width: false,
    1422        initialWidth: "600",
     
    2129        scalePhotos: true,
    2230        scrolling: true,
    23         inline: false,
    24         html: false,
    25         iframe: false,
    26         fastIframe: true,
    27         photo: false,
    28         href: false,
    29         title: false,
    30         rel: false,
    3131        opacity: 0.9,
    3232        preloading: true,
    3333        className: false,
    34        
    35         // alternate image paths for high-res displays
    36         retinaImage: false,
    37         retinaUrl: false,
    38         retinaSuffix: '@2x.$1',
    39 
    40         // internationalization
    41         current: "image {current} of {total}",
    42         previous: "previous",
    43         next: "next",
    44         close: "close",
    45         xhrError: "This content failed to load.",
    46         imgError: "This image failed to load.",
    47 
    48         open: false,
    49         returnFocus: true,
    50         reposition: true,
    51         loop: true,
    52         slideshow: false,
    53         slideshowAuto: true,
    54         slideshowSpeed: 2500,
    55         slideshowStart: "start slideshow",
    56         slideshowStop: "stop slideshow",
    57         photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico)((#|\?).*)?$/i,
    58 
    59         onOpen: false,
    60         onLoad: false,
    61         onComplete: false,
    62         onCleanup: false,
    63         onClosed: false,
    6434        overlayClose: true,
    6535        escKey: true,
     
    7040        right: false,
    7141        fixed: false,
    72         data: undefined
     42        data: undefined,
     43        closeButton: true,
     44        fastIframe: true,
     45        open: false,
     46        reposition: true,
     47        loop: true,
     48        slideshow: false,
     49        slideshowAuto: true,
     50        slideshowSpeed: 2500,
     51        slideshowStart: "start slideshow",
     52        slideshowStop: "stop slideshow",
     53        photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i,
     54
     55        // alternate image paths for high-res displays
     56        retinaImage: false,
     57        retinaUrl: false,
     58        retinaSuffix: '@2x.$1',
     59
     60        // internationalization
     61        current: "image {current} of {total}",
     62        previous: "previous",
     63        next: "next",
     64        close: "close",
     65        xhrError: "This content failed to load.",
     66        imgError: "This image failed to load.",
     67
     68        // accessbility
     69        returnFocus: true,
     70        trapFocus: true,
     71
     72        // callbacks
     73        onOpen: false,
     74        onLoad: false,
     75        onComplete: false,
     76        onCleanup: false,
     77        onClosed: false,
     78
     79        rel: function() {
     80            return this.rel;
     81        },
     82        href: function() {
     83            // using this.href would give the absolute url, when the href may have been intended as a selector (e.g. '#container')
     84            return $(this).attr('href');
     85        },
     86        title: function() {
     87            return this.title;
     88        },
     89        createImg: function() {
     90            var img = new Image();
     91            var attrs = $(this).data('cbox-img-attrs');
     92
     93            if (typeof attrs === 'object') {
     94                $.each(attrs, function(key, val){
     95                    img[key] = val;
     96                });
     97            }
     98
     99            return img;
     100        },
     101        createIframe: function() {
     102            var iframe = document.createElement('iframe');
     103            var attrs = $(this).data('cbox-iframe-attrs');
     104
     105            if (typeof attrs === 'object') {
     106                $.each(attrs, function(key, val){
     107                    iframe[key] = val;
     108                });
     109            }
     110
     111            if ('frameBorder' in iframe) {
     112                iframe.frameBorder = 0;
     113            }
     114            if ('allowTransparency' in iframe) {
     115                iframe.allowTransparency = "true";
     116            }
     117            iframe.name = (new Date()).getTime(); // give the iframe a unique name to prevent caching
     118            iframe.allowFullscreen = true;
     119
     120            return iframe;
     121        }
    73122    },
    74    
     123
    75124    // Abstracting the HTML and event identifiers for easy rebranding
    76125    colorbox = 'colorbox',
    77126    prefix = 'cbox',
    78127    boxElement = prefix + 'Element',
    79    
     128
    80129    // Events
    81130    event_open = prefix + '_open',
     
    107156    $close,
    108157    $groupControls,
    109     $events = $('<a/>'),
    110    
     158    $events = $('<a/>'), // $({}) would be preferred, but there is an issue with jQuery 1.4.2
     159
    111160    // Variables for cached values or use across multiple functions
    112161    settings,
     
    115164    loadedHeight,
    116165    loadedWidth,
    117     element,
    118166    index,
    119167    photo,
     
    124172    publicMethod,
    125173    div = "div",
    126     className,
    127174    requests = 0,
     175    previousCSS = {},
    128176    init;
    129177
     
    131179    // HELPER FUNCTIONS
    132180    // ****************
    133    
    134     // Convience function for creating new jQuery objects
     181
     182    // Convenience function for creating new jQuery objects
    135183    function $tag(tag, id, css) {
    136184        var element = document.createElement(tag);
     
    146194        return $(element);
    147195    }
    148    
     196
    149197    // Get the window height using innerHeight when available to avoid an issue with iOS
    150198    // http://bugs.jquery.com/ticket/6724
    151199    function winheight() {
    152200        return window.innerHeight ? window.innerHeight : $(window).height();
     201    }
     202
     203    function Settings(element, options) {
     204        if (options !== Object(options)) {
     205            options = {};
     206        }
     207
     208        this.cache = {};
     209        this.el = element;
     210
     211        this.value = function(key) {
     212            var dataAttr;
     213
     214            if (this.cache[key] === undefined) {
     215                dataAttr = $(this.el).attr('data-cbox-'+key);
     216
     217                if (dataAttr !== undefined) {
     218                    this.cache[key] = dataAttr;
     219                } else if (options[key] !== undefined) {
     220                    this.cache[key] = options[key];
     221                } else if (defaults[key] !== undefined) {
     222                    this.cache[key] = defaults[key];
     223                }
     224            }
     225
     226            return this.cache[key];
     227        };
     228
     229        this.get = function(key) {
     230            var value = this.value(key);
     231            return $.isFunction(value) ? value.call(this.el, this) : value;
     232        };
    153233    }
    154234
     
    158238        max = $related.length,
    159239        newIndex = (index + increment) % max;
    160        
     240
    161241        return (newIndex < 0) ? max + newIndex : newIndex;
    162242    }
     
    166246        return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10));
    167247    }
    168    
     248
    169249    // Checks an href to see if it is a photo.
    170250    // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex.
    171251    function isImage(settings, url) {
    172         return settings.photo || settings.photoRegex.test(url);
     252        return settings.get('photo') || settings.get('photoRegex').test(url);
    173253    }
    174254
    175255    function retinaUrl(settings, url) {
    176         return settings.retinaUrl && window.devicePixelRatio > 1 ? url.replace(settings.photoRegex, settings.retinaSuffix) : url;
     256        return settings.get('retinaUrl') && window.devicePixelRatio > 1 ? url.replace(settings.get('photoRegex'), settings.get('retinaSuffix')) : url;
    177257    }
    178258
    179259    function trapFocus(e) {
    180         if ('contains' in $box[0] && !$box[0].contains(e.target)) {
     260        if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) {
    181261            e.stopPropagation();
    182262            $box.focus();
     
    184264    }
    185265
    186     // Assigns function results to their respective properties
    187     function makeSettings() {
    188         var i,
    189             data = $.data(element, colorbox);
    190        
    191         if (data == null) {
    192             settings = $.extend({}, defaults);
    193             if (console && console.log) {
    194                 console.log('Error: cboxElement missing settings object');
     266    function setClass(str) {
     267        if (setClass.str !== str) {
     268            $box.add($overlay).removeClass(setClass.str).addClass(str);
     269            setClass.str = str;
     270        }
     271    }
     272
     273    function getRelated(rel) {
     274        index = 0;
     275
     276        if (rel && rel !== false && rel !== 'nofollow') {
     277            $related = $('.' + boxElement).filter(function () {
     278                var options = $.data(this, colorbox);
     279                var settings = new Settings(this, options);
     280                return (settings.get('rel') === rel);
     281            });
     282            index = $related.index(settings.el);
     283
     284            // Check direct calls to Colorbox.
     285            if (index === -1) {
     286                $related = $related.add(settings.el);
     287                index = $related.length - 1;
    195288            }
    196289        } else {
    197             settings = $.extend({}, data);
    198         }
    199        
    200         for (i in settings) {
    201             if ($.isFunction(settings[i]) && i.slice(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
    202                 settings[i] = settings[i].call(element);
    203             }
    204         }
    205        
    206         settings.rel = settings.rel || element.rel || $(element).data('rel') || 'nofollow';
    207         settings.href = settings.href || $(element).attr('href');
    208         settings.title = settings.title || element.title;
    209        
    210         if (typeof settings.href === "string") {
    211             settings.href = $.trim(settings.href);
    212         }
    213     }
    214 
    215     function trigger(event, callback) {
     290            $related = $(settings.el);
     291        }
     292    }
     293
     294    function trigger(event) {
    216295        // for external use
    217296        $(document).trigger(event);
    218 
    219297        // for internal use
    220         $events.trigger(event);
    221 
    222         if ($.isFunction(callback)) {
    223             callback.call(element);
    224         }
    225     }
    226 
    227     // Slideshow functionality
    228     function slideshow() {
    229         var
    230         timeOut,
    231         className = prefix + "Slideshow_",
    232         click = "click." + prefix,
    233         clear,
    234         set,
    235         start,
    236         stop;
    237        
    238         if (settings.slideshow && $related[1]) {
    239             clear = function () {
    240                 clearTimeout(timeOut);
    241             };
    242 
    243             set = function () {
    244                 if (settings.loop || $related[index + 1]) {
    245                     timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
    246                 }
    247             };
    248 
    249             start = function () {
    250                 $slideshow
    251                     .html(settings.slideshowStop)
    252                     .unbind(click)
    253                     .one(click, stop);
    254 
    255                 $events
    256                     .bind(event_complete, set)
    257                     .bind(event_load, clear)
    258                     .bind(event_cleanup, stop);
    259 
    260                 $box.removeClass(className + "off").addClass(className + "on");
    261             };
    262            
    263             stop = function () {
     298        $events.triggerHandler(event);
     299    }
     300
     301    var slideshow = (function(){
     302        var active,
     303            className = prefix + "Slideshow_",
     304            click = "click." + prefix,
     305            timeOut;
     306
     307        function clear () {
     308            clearTimeout(timeOut);
     309        }
     310
     311        function set() {
     312            if (settings.get('loop') || $related[index + 1]) {
    264313                clear();
    265                
    266                 $events
    267                     .unbind(event_complete, set)
    268                     .unbind(event_load, clear)
    269                     .unbind(event_cleanup, stop);
    270                
    271                 $slideshow
    272                     .html(settings.slideshowStart)
    273                     .unbind(click)
    274                     .one(click, function () {
    275                         publicMethod.next();
     314                timeOut = setTimeout(publicMethod.next, settings.get('slideshowSpeed'));
     315            }
     316        }
     317
     318        function start() {
     319            $slideshow
     320                .html(settings.get('slideshowStop'))
     321                .unbind(click)
     322                .one(click, stop);
     323
     324            $events
     325                .bind(event_complete, set)
     326                .bind(event_load, clear);
     327
     328            $box.removeClass(className + "off").addClass(className + "on");
     329        }
     330
     331        function stop() {
     332            clear();
     333
     334            $events
     335                .unbind(event_complete, set)
     336                .unbind(event_load, clear);
     337
     338            $slideshow
     339                .html(settings.get('slideshowStart'))
     340                .unbind(click)
     341                .one(click, function () {
     342                    publicMethod.next();
     343                    start();
     344                });
     345
     346            $box.removeClass(className + "on").addClass(className + "off");
     347        }
     348
     349        function reset() {
     350            active = false;
     351            $slideshow.hide();
     352            clear();
     353            $events
     354                .unbind(event_complete, set)
     355                .unbind(event_load, clear);
     356            $box.removeClass(className + "off " + className + "on");
     357        }
     358
     359        return function(){
     360            if (active) {
     361                if (!settings.get('slideshow')) {
     362                    $events.unbind(event_cleanup, reset);
     363                    reset();
     364                }
     365            } else {
     366                if (settings.get('slideshow') && $related[1]) {
     367                    active = true;
     368                    $events.one(event_cleanup, reset);
     369                    if (settings.get('slideshowAuto')) {
    276370                        start();
    277                     });
    278 
    279                 $box.removeClass(className + "on").addClass(className + "off");
    280             };
    281            
    282             if (settings.slideshowAuto) {
    283                 start();
    284             } else {
    285                 stop();
    286             }
    287         } else {
    288             $box.removeClass(className + "off " + className + "on");
    289         }
    290     }
    291 
    292     function launch(target) {
     371                    } else {
     372                        stop();
     373                    }
     374                    $slideshow.show();
     375                }
     376            }
     377        };
     378
     379    }());
     380
     381
     382    function launch(element) {
     383        var options;
     384
    293385        if (!closing) {
    294            
    295             element = target;
    296            
    297             makeSettings();
    298            
    299             $related = $(element);
    300            
    301             index = 0;
    302            
    303             if (settings.rel !== 'nofollow') {
    304                 $related = $('.' + boxElement).filter(function () {
    305                     var data = $.data(this, colorbox),
    306                         relRelated;
    307 
    308                     if (data) {
    309                         relRelated =  $(this).data('rel') || data.rel || this.rel;
    310                     }
    311                    
    312                     return (relRelated === settings.rel);
    313                 });
    314                 index = $related.index(element);
    315                
    316                 // Check direct calls to Colorbox.
    317                 if (index === -1) {
    318                     $related = $related.add(element);
    319                     index = $related.length - 1;
    320                 }
    321             }
    322            
    323             $overlay.css({
    324                 opacity: parseFloat(settings.opacity),
    325                 cursor: settings.overlayClose ? "pointer" : "auto",
    326                 visibility: 'visible'
    327             }).show();
    328            
    329 
    330             if (className) {
    331                 $box.add($overlay).removeClass(className);
    332             }
    333             if (settings.className) {
    334                 $box.add($overlay).addClass(settings.className);
    335             }
    336             className = settings.className;
    337 
    338             $close.html(settings.close).show();
     386
     387            options = $(element).data(colorbox);
     388
     389            settings = new Settings(element, options);
     390
     391            getRelated(settings.get('rel'));
    339392
    340393            if (!open) {
    341394                open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
    342                
     395
     396                setClass(settings.get('className'));
     397
    343398                // Show colorbox so the sizes can be calculated in older versions of jQuery
    344                 $box.css({visibility:'hidden', display:'block'});
    345                
    346                 $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden').appendTo($content);
     399                $box.css({visibility:'hidden', display:'block', opacity:''});
     400
     401                $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden; visibility:hidden');
     402                $content.css({width:'', height:''}).append($loaded);
    347403
    348404                // Cache values needed for size calculations
     
    351407                loadedHeight = $loaded.outerHeight(true);
    352408                loadedWidth = $loaded.outerWidth(true);
    353                
    354                
     409
    355410                // Opens inital empty Colorbox prior to content being loaded.
    356                 settings.w = setSize(settings.initialWidth, 'x');
    357                 settings.h = setSize(settings.initialHeight, 'y');
     411                var initialWidth = setSize(settings.get('initialWidth'), 'x');
     412                var initialHeight = setSize(settings.get('initialHeight'), 'y');
     413                var maxWidth = settings.get('maxWidth');
     414                var maxHeight = settings.get('maxHeight');
     415
     416                settings.w = Math.max((maxWidth !== false ? Math.min(initialWidth, setSize(maxWidth, 'x')) : initialWidth) - loadedWidth - interfaceWidth, 0);
     417                settings.h = Math.max((maxHeight !== false ? Math.min(initialHeight, setSize(maxHeight, 'y')) : initialHeight) - loadedHeight - interfaceHeight, 0);
     418
     419                $loaded.css({width:'', height:settings.h});
    358420                publicMethod.position();
    359421
    360                 slideshow();
    361 
    362                 trigger(event_open, settings.onOpen);
    363                
     422                trigger(event_open);
     423                settings.get('onOpen');
     424
    364425                $groupControls.add($title).hide();
    365426
    366427                $box.focus();
    367                
    368                 // Confine focus to the modal
    369                 // Uses event capturing that is not supported in IE8-
    370                 if (document.addEventListener) {
    371 
    372                     document.addEventListener('focus', trapFocus, true);
    373                    
     428
     429                if (settings.get('trapFocus')) {
     430                    // Confine focus to the modal
     431                    // Uses event capturing that is not supported in IE8-
     432                    if (document.addEventListener) {
     433
     434                        document.addEventListener('focus', trapFocus, true);
     435
     436                        $events.one(event_closed, function () {
     437                            document.removeEventListener('focus', trapFocus, true);
     438                        });
     439                    }
     440                }
     441
     442                // Return focus on closing
     443                if (settings.get('returnFocus')) {
    374444                    $events.one(event_closed, function () {
    375                         document.removeEventListener('focus', trapFocus, true);
     445                        $(settings.el).focus();
    376446                    });
    377447                }
    378 
    379                 // Return focus on closing
    380                 if (settings.returnFocus) {
    381                     $events.one(event_closed, function () {
    382                         $(element).focus();
    383                     });
    384                 }
    385             }
    386            
     448            }
     449
     450            var opacity = parseFloat(settings.get('opacity'));
     451            $overlay.css({
     452                opacity: opacity === opacity ? opacity : '',
     453                cursor: settings.get('overlayClose') ? 'pointer' : '',
     454                visibility: 'visible'
     455            }).show();
     456
     457            if (settings.get('closeButton')) {
     458                $close.html(settings.get('close')).appendTo($content);
     459            } else {
     460                $close.appendTo('<div/>'); // replace with .detach() when dropping jQuery < 1.4
     461            }
     462
    387463            load();
    388464        }
     
    392468    // so that the browser will go ahead and load the CSS background images.
    393469    function appendHTML() {
    394         if (!$box && document.body) {
     470        if (!$box) {
    395471            init = false;
    396472            $window = $(window);
     
    402478            }).hide();
    403479            $overlay = $tag(div, "Overlay").hide();
    404             $loadingOverlay = $tag(div, "LoadingOverlay").add($tag(div, "LoadingGraphic"));
     480            $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]);
    405481            $wrap = $tag(div, "Wrapper");
    406482            $content = $tag(div, "Content").append(
    407483                $title = $tag(div, "Title"),
    408484                $current = $tag(div, "Current"),
    409                 $prev = $tag('button', "Previous"),
    410                 $next = $tag('button', "Next"),
    411                 $slideshow = $tag('button', "Slideshow"),
    412                 $loadingOverlay,
    413                 $close = $tag('button', "Close")
     485                $prev = $('<button type="button"/>').attr({id:prefix+'Previous'}),
     486                $next = $('<button type="button"/>').attr({id:prefix+'Next'}),
     487                $slideshow = $('<button type="button"/>').attr({id:prefix+'Slideshow'}),
     488                $loadingOverlay
    414489            );
    415            
     490
     491            $close = $('<button type="button"/>').attr({id:prefix+'Close'});
     492
    416493            $wrap.append( // The 3x3 Grid that makes up Colorbox
    417494                $tag(div).append(
     
    431508                )
    432509            ).find('div div').css({'float': 'left'});
    433            
    434             $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none');
    435            
     510
     511            $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none; max-width:none;');
     512
    436513            $groupControls = $next.add($prev).add($current).add($slideshow);
    437 
     514        }
     515        if (document.body && !$box.parent().length) {
    438516            $(document.body).append($overlay, $box.append($wrap, $loadingBay));
    439517        }
     
    445523            // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt.
    446524            // See: http://jacklmoore.com/notes/click-events/
    447             if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.control)) {
     525            if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) {
    448526                e.preventDefault();
    449527                launch(this);
     
    466544                });
    467545                $overlay.click(function () {
    468                     if (settings.overlayClose) {
     546                    if (settings.get('overlayClose')) {
    469547                        publicMethod.close();
    470548                    }
    471549                });
    472                
     550
    473551                // Key Bindings
    474552                $(document).bind('keydown.' + prefix, function (e) {
    475553                    var key = e.keyCode;
    476                     if (open && settings.escKey && key === 27) {
     554                    if (open && settings.get('escKey') && key === 27) {
    477555                        e.preventDefault();
    478556                        publicMethod.close();
    479557                    }
    480                     if (open && settings.arrowKey && $related[1] && !e.altKey) {
     558                    if (open && settings.get('arrowKey') && $related[1] && !e.altKey) {
    481559                        if (key === 37) {
    482560                            e.preventDefault();
     
    505583
    506584    // Don't do anything if Colorbox already exists.
    507     if ($.colorbox) {
     585    if ($[colorbox]) {
    508586        return;
    509587    }
     
    518596    // Usage from within an iframe: parent.jQuery.colorbox.close();
    519597    // ****************
    520    
     598
    521599    publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
    522         var $this = this;
    523        
     600        var settings;
     601        var $obj = this;
     602
    524603        options = options || {};
    525        
     604
     605        if ($.isFunction($obj)) { // assume a call to $.colorbox
     606            $obj = $('<a/>');
     607            options.open = true;
     608        }
     609
     610        if (!$obj[0]) { // colorbox being applied to empty collection
     611            return $obj;
     612        }
     613
    526614        appendHTML();
    527615
    528616        if (addBindings()) {
    529             if ($.isFunction($this)) { // assume a call to $.colorbox
    530                 $this = $('<a/>');
    531                 options.open = true;
    532             } else if (!$this[0]) { // colorbox being applied to empty collection
    533                 return $this;
    534             }
    535            
     617
    536618            if (callback) {
    537619                options.onComplete = callback;
    538620            }
    539            
    540             $this.each(function () {
    541                 $.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
     621
     622            $obj.each(function () {
     623                var old = $.data(this, colorbox) || {};
     624                $.data(this, colorbox, $.extend(old, options));
    542625            }).addClass(boxElement);
    543            
    544             if (($.isFunction(options.open) && options.open.call($this)) || options.open) {
    545                 launch($this[0]);
    546             }
    547         }
    548        
    549         return $this;
     626
     627            settings = new Settings($obj[0], options);
     628
     629            if (settings.get('open')) {
     630                launch($obj[0]);
     631            }
     632        }
     633
     634        return $obj;
    550635    };
    551636
     
    558643        scrollTop,
    559644        scrollLeft;
    560        
     645
    561646        $window.unbind('resize.' + prefix);
    562647
     
    567652        scrollLeft = $window.scrollLeft();
    568653
    569         if (settings.fixed) {
     654        if (settings.get('fixed')) {
    570655            offset.top -= scrollTop;
    571656            offset.left -= scrollLeft;
     
    578663
    579664        // keeps the top and left positions within the browser's viewport.
    580         if (settings.right !== false) {
    581             left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.right, 'x'), 0);
    582         } else if (settings.left !== false) {
    583             left += setSize(settings.left, 'x');
     665        if (settings.get('right') !== false) {
     666            left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.get('right'), 'x'), 0);
     667        } else if (settings.get('left') !== false) {
     668            left += setSize(settings.get('left'), 'x');
    584669        } else {
    585670            left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
    586671        }
    587        
    588         if (settings.bottom !== false) {
    589             top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
    590         } else if (settings.top !== false) {
    591             top += setSize(settings.top, 'y');
     672
     673        if (settings.get('bottom') !== false) {
     674            top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.get('bottom'), 'y'), 0);
     675        } else if (settings.get('top') !== false) {
     676            top += setSize(settings.get('top'), 'y');
    592677        } else {
    593678            top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
     
    596681        $box.css({top: offset.top, left: offset.left, visibility:'visible'});
    597682
    598         // setting the speed to 0 to reduce the delay between same-sized content.
    599         speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed || 0;
    600        
    601683        // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
    602684        // but it has to be shrank down around the size of div#colorbox when it's done.  If not,
    603685        // it can invoke an obscure IE bug when using iframes.
    604686        $wrap[0].style.width = $wrap[0].style.height = "9999px";
    605        
    606         function modalDimensions(that) {
    607             $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = (parseInt(that.style.width,10) - interfaceWidth)+'px';
    608             $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = (parseInt(that.style.height,10) - interfaceHeight)+'px';
     687
     688        function modalDimensions() {
     689            $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = (parseInt($box[0].style.width,10) - interfaceWidth)+'px';
     690            $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = (parseInt($box[0].style.height,10) - interfaceHeight)+'px';
    609691        }
    610692
    611693        css = {width: settings.w + loadedWidth + interfaceWidth, height: settings.h + loadedHeight + interfaceHeight, top: top, left: left};
    612694
    613         if(speed===0){ // temporary workaround to side-step jQuery-UI 1.8 bug (http://bugs.jquery.com/ticket/12273)
     695        // setting the speed to 0 if the content hasn't changed size or position
     696        if (speed) {
     697            var tempSpeed = 0;
     698            $.each(css, function(i){
     699                if (css[i] !== previousCSS[i]) {
     700                    tempSpeed = speed;
     701                    return;
     702                }
     703            });
     704            speed = tempSpeed;
     705        }
     706
     707        previousCSS = css;
     708
     709        if (!speed) {
    614710            $box.css(css);
    615711        }
     712
    616713        $box.dequeue().animate(css, {
    617             duration: speed,
     714            duration: speed || 0,
    618715            complete: function () {
    619                 modalDimensions(this);
    620                
     716                modalDimensions();
     717
    621718                active = false;
    622                
     719
    623720                // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
    624721                $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
    625722                $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
    626                
    627                 if (settings.reposition) {
     723
     724                if (settings.get('reposition')) {
    628725                    setTimeout(function () {  // small delay before binding onresize due to an IE8 bug.
    629726                        $window.bind('resize.' + prefix, publicMethod.position);
     
    631728                }
    632729
    633                 if (loadedCallback) {
     730                if ($.isFunction(loadedCallback)) {
    634731                    loadedCallback();
    635732                }
    636733            },
    637             step: function () {
    638                 modalDimensions(this);
    639             }
     734            step: modalDimensions
    640735        });
    641736    };
    642737
    643738    publicMethod.resize = function (options) {
     739        var scrolltop;
     740
    644741        if (open) {
    645742            options = options || {};
    646            
     743
    647744            if (options.width) {
    648745                settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
    649746            }
     747
    650748            if (options.innerWidth) {
    651749                settings.w = setSize(options.innerWidth, 'x');
    652750            }
     751
    653752            $loaded.css({width: settings.w});
    654            
     753
    655754            if (options.height) {
    656755                settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
    657756            }
     757
    658758            if (options.innerHeight) {
    659759                settings.h = setSize(options.innerHeight, 'y');
    660760            }
     761
    661762            if (!options.innerHeight && !options.height) {
     763                scrolltop = $loaded.scrollTop();
    662764                $loaded.css({height: "auto"});
    663765                settings.h = $loaded.height();
    664766            }
     767
    665768            $loaded.css({height: settings.h});
    666            
    667             publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
     769
     770            if(scrolltop) {
     771                $loaded.scrollTop(scrolltop);
     772            }
     773
     774            publicMethod.position(settings.get('transition') === "none" ? 0 : settings.get('speed'));
    668775        }
    669776    };
     
    673780            return;
    674781        }
    675        
    676         var callback, speed = settings.transition === "none" ? 0 : settings.speed;
    677 
    678         $loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
     782
     783        var callback, speed = settings.get('transition') === "none" ? 0 : settings.get('speed');
     784
     785        $loaded.remove();
    679786
    680787        $loaded = $tag(div, 'LoadedContent').append(object);
    681        
     788
    682789        function getWidth() {
    683790            settings.w = settings.w || $loaded.width();
     
    690797            return settings.h;
    691798        }
    692        
     799
    693800        $loaded.hide()
    694801        .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
    695         .css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
     802        .css({width: getWidth(), overflow: settings.get('scrolling') ? 'auto' : 'hidden'})
    696803        .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
    697804        .prependTo($content);
    698        
     805
    699806        $loadingBay.hide();
    700        
     807
    701808        // floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
    702        
     809
    703810        $(photo).css({'float': 'none'});
     811
     812        setClass(settings.get('className'));
    704813
    705814        callback = function () {
    706815            var total = $related.length,
    707816                iframe,
    708                 frameBorder = 'frameBorder',
    709                 allowTransparency = 'allowTransparency',
    710817                complete;
    711            
     818
    712819            if (!open) {
    713820                return;
    714821            }
    715            
    716             function removeFilter() { // Needed for IE7 & IE8 in versions of jQuery prior to 1.7.2
     822
     823            function removeFilter() { // Needed for IE8 in versions of jQuery prior to 1.7.2
    717824                if ($.support.opacity === false) {
    718825                    $box[0].style.removeAttribute('filter');
    719826                }
    720827            }
    721            
     828
    722829            complete = function () {
    723830                clearTimeout(loadingTimer);
    724831                $loadingOverlay.hide();
    725                 trigger(event_complete, settings.onComplete);
     832                trigger(event_complete);
     833                settings.get('onComplete');
    726834            };
    727835
    728            
    729             $title.html(settings.title).add($loaded).show();
    730            
     836
     837            $title.html(settings.get('title')).show();
     838            $loaded.show();
     839
    731840            if (total > 1) { // handle grouping
    732                 if (typeof settings.current === "string") {
    733                     $current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show();
    734                 }
    735                
    736                 $next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
    737                 $prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
    738                
    739                 if (settings.slideshow) {
    740                     $slideshow.show();
    741                 }
    742                
     841                if (typeof settings.get('current') === "string") {
     842                    $current.html(settings.get('current').replace('{current}', index + 1).replace('{total}', total)).show();
     843                }
     844
     845                $next[(settings.get('loop') || index < total - 1) ? "show" : "hide"]().html(settings.get('next'));
     846                $prev[(settings.get('loop') || index) ? "show" : "hide"]().html(settings.get('previous'));
     847
     848                slideshow();
     849
    743850                // Preloads images within a rel group
    744                 if (settings.preloading) {
     851                if (settings.get('preloading')) {
    745852                    $.each([getIndex(-1), getIndex(1)], function(){
    746                         var src,
    747                             img,
     853                        var img,
    748854                            i = $related[this],
    749                             data = $.data(i, colorbox);
    750 
    751                         if (data && data.href) {
    752                             src = data.href;
    753                             if ($.isFunction(src)) {
    754                                 src = src.call(i);
    755                             }
    756                         } else {
    757                             src = $(i).attr('href');
    758                         }
    759 
    760                         if (src && isImage(data, src)) {
    761                             src = retinaUrl(data, src);
    762                             img = new Image();
     855                            settings = new Settings(i, $.data(i, colorbox)),
     856                            src = settings.get('href');
     857
     858                        if (src && isImage(settings, src)) {
     859                            src = retinaUrl(settings, src);
     860                            img = document.createElement('img');
    763861                            img.src = src;
    764862                        }
     
    768866                $groupControls.hide();
    769867            }
    770            
    771             if (settings.iframe) {
    772                 iframe = $tag('iframe')[0];
    773                
    774                 if (frameBorder in iframe) {
    775                     iframe[frameBorder] = 0;
    776                 }
    777                
    778                 if (allowTransparency in iframe) {
    779                     iframe[allowTransparency] = "true";
    780                 }
    781 
    782                 if (!settings.scrolling) {
     868
     869            if (settings.get('iframe')) {
     870
     871                iframe = settings.get('createIframe');
     872
     873                if (!settings.get('scrolling')) {
    783874                    iframe.scrolling = "no";
    784875                }
    785                
     876
    786877                $(iframe)
    787878                    .attr({
    788                         src: settings.href,
    789                         name: (new Date()).getTime(), // give the iframe a unique name to prevent caching
    790                         'class': prefix + 'Iframe',
    791                         allowFullScreen : true, // allow HTML5 video to go fullscreen
    792                         webkitAllowFullScreen : true,
    793                         mozallowfullscreen : true
     879                        src: settings.get('href'),
     880                        'class': prefix + 'Iframe'
    794881                    })
    795882                    .one('load', complete)
    796883                    .appendTo($loaded);
    797                
     884
    798885                $events.one(event_purge, function () {
    799886                    iframe.src = "//about:blank";
    800887                });
    801888
    802                 if (settings.fastIframe) {
     889                if (settings.get('fastIframe')) {
    803890                    $(iframe).trigger('load');
    804891                }
     
    806893                complete();
    807894            }
    808            
    809             if (settings.transition === 'fade') {
     895
     896            if (settings.get('transition') === 'fade') {
    810897                $box.fadeTo(speed, 1, removeFilter);
    811898            } else {
     
    813900            }
    814901        };
    815        
    816         if (settings.transition === 'fade') {
     902
     903        if (settings.get('transition') === 'fade') {
    817904            $box.fadeTo(speed, 0, function () {
    818905                publicMethod.position(0, callback);
     
    825912    function load () {
    826913        var href, setResize, prep = publicMethod.prep, $inline, request = ++requests;
    827        
     914
    828915        active = true;
    829        
     916
    830917        photo = false;
    831        
    832         element = $related[index];
    833        
    834         makeSettings();
    835        
     918
    836919        trigger(event_purge);
    837        
    838         trigger(event_load, settings.onLoad);
    839        
    840         settings.h = settings.height ?
    841                 setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
    842                 settings.innerHeight && setSize(settings.innerHeight, 'y');
    843        
    844         settings.w = settings.width ?
    845                 setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
    846                 settings.innerWidth && setSize(settings.innerWidth, 'x');
    847        
     920        trigger(event_load);
     921        settings.get('onLoad');
     922
     923        settings.h = settings.get('height') ?
     924                setSize(settings.get('height'), 'y') - loadedHeight - interfaceHeight :
     925                settings.get('innerHeight') && setSize(settings.get('innerHeight'), 'y');
     926
     927        settings.w = settings.get('width') ?
     928                setSize(settings.get('width'), 'x') - loadedWidth - interfaceWidth :
     929                settings.get('innerWidth') && setSize(settings.get('innerWidth'), 'x');
     930
    848931        // Sets the minimum dimensions for use in image scaling
    849932        settings.mw = settings.w;
    850933        settings.mh = settings.h;
    851        
     934
    852935        // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
    853936        // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
    854         if (settings.maxWidth) {
    855             settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
     937        if (settings.get('maxWidth')) {
     938            settings.mw = setSize(settings.get('maxWidth'), 'x') - loadedWidth - interfaceWidth;
    856939            settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
    857940        }
    858         if (settings.maxHeight) {
    859             settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
     941        if (settings.get('maxHeight')) {
     942            settings.mh = setSize(settings.get('maxHeight'), 'y') - loadedHeight - interfaceHeight;
    860943            settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
    861944        }
    862        
    863         href = settings.href;
    864        
     945
     946        href = settings.get('href');
     947
    865948        loadingTimer = setTimeout(function () {
    866949            $loadingOverlay.show();
    867950        }, 100);
    868        
    869         if (settings.inline) {
     951
     952        if (settings.get('inline')) {
     953            var $target = $(href).eq(0);
    870954            // Inserts an empty placeholder where inline content is being pulled from.
    871955            // An event is bound to put inline content back when Colorbox closes or loads new content.
    872             $inline = $tag(div).hide().insertBefore($(href)[0]);
     956            $inline = $('<div>').hide().insertBefore($target);
    873957
    874958            $events.one(event_purge, function () {
    875                 $inline.replaceWith($loaded.children());
     959                $inline.replaceWith($target);
    876960            });
    877961
    878             prep($(href));
    879         } else if (settings.iframe) {
     962            prep($target);
     963        } else if (settings.get('iframe')) {
    880964            // IFrame element won't be added to the DOM until it is ready to be displayed,
    881965            // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
    882966            prep(" ");
    883         } else if (settings.html) {
    884             prep(settings.html);
     967        } else if (settings.get('html')) {
     968            prep(settings.get('html'));
    885969        } else if (isImage(settings, href)) {
    886970
    887971            href = retinaUrl(settings, href);
    888972
    889             $(photo = new Image())
     973            photo = settings.get('createImg');
     974
     975            $(photo)
    890976            .addClass(prefix + 'Photo')
    891             .bind('error',function () {
    892                 settings.title = false;
    893                 prep($tag(div, 'Error').html(settings.imgError));
     977            .bind('error.'+prefix,function () {
     978                prep($tag(div, 'Error').html(settings.get('imgError')));
    894979            })
    895980            .one('load', function () {
    896                 var percent;
    897 
    898981                if (request !== requests) {
    899982                    return;
    900983                }
    901984
    902                 if (settings.retinaImage && window.devicePixelRatio > 1) {
    903                     photo.height = photo.height / window.devicePixelRatio;
    904                     photo.width = photo.width / window.devicePixelRatio;
    905                 }
    906 
    907                 if (settings.scalePhotos) {
    908                     setResize = function () {
    909                         photo.height -= photo.height * percent;
    910                         photo.width -= photo.width * percent;
    911                     };
    912                     if (settings.mw && photo.width > settings.mw) {
    913                         percent = (photo.width - settings.mw) / photo.width;
    914                         setResize();
     985                // A small pause because some browsers will occasionally report a
     986                // img.width and img.height of zero immediately after the img.onload fires
     987                setTimeout(function(){
     988                    var percent;
     989
     990                    if (settings.get('retinaImage') && window.devicePixelRatio > 1) {
     991                        photo.height = photo.height / window.devicePixelRatio;
     992                        photo.width = photo.width / window.devicePixelRatio;
    915993                    }
    916                     if (settings.mh && photo.height > settings.mh) {
    917                         percent = (photo.height - settings.mh) / photo.height;
    918                         setResize();
     994
     995                    if (settings.get('scalePhotos')) {
     996                        setResize = function () {
     997                            photo.height -= photo.height * percent;
     998                            photo.width -= photo.width * percent;
     999                        };
     1000                        if (settings.mw && photo.width > settings.mw) {
     1001                            percent = (photo.width - settings.mw) / photo.width;
     1002                            setResize();
     1003                        }
     1004                        if (settings.mh && photo.height > settings.mh) {
     1005                            percent = (photo.height - settings.mh) / photo.height;
     1006                            setResize();
     1007                        }
    9191008                    }
    920                 }
    921                
    922                 if (settings.h) {
    923                     photo.style.marginTop = Math.max(settings.mh - photo.height, 0) / 2 + 'px';
    924                 }
    925                
    926                 if ($related[1] && (settings.loop || $related[index + 1])) {
    927                     photo.style.cursor = 'pointer';
    928                     photo.onclick = function () {
    929                         publicMethod.next();
    930                     };
    931                 }
    932 
    933                 setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
     1009
     1010                    if (settings.h) {
     1011                        photo.style.marginTop = Math.max(settings.mh - photo.height, 0) / 2 + 'px';
     1012                    }
     1013
     1014                    if ($related[1] && (settings.get('loop') || $related[index + 1])) {
     1015                        photo.style.cursor = 'pointer';
     1016
     1017                        $(photo).bind('click.'+prefix, function () {
     1018                            publicMethod.next();
     1019                        });
     1020                    }
     1021
     1022                    photo.style.width = photo.width + 'px';
     1023                    photo.style.height = photo.height + 'px';
    9341024                    prep(photo);
    9351025                }, 1);
    9361026            });
    937            
    938             setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
    939                 photo.src = href;
    940             }, 1);
     1027
     1028            photo.src = href;
     1029
    9411030        } else if (href) {
    942             $loadingBay.load(href, settings.data, function (data, status) {
     1031            $loadingBay.load(href, settings.get('data'), function (data, status) {
    9431032                if (request === requests) {
    944                     prep(status === 'error' ? $tag(div, 'Error').html(settings.xhrError) : $(this).contents());
     1033                    prep(status === 'error' ? $tag(div, 'Error').html(settings.get('xhrError')) : $(this).contents());
    9451034                }
    9461035            });
    9471036        }
    9481037    }
    949        
     1038
    9501039    // Navigates to the next page/image in a set.
    9511040    publicMethod.next = function () {
    952         if (!active && $related[1] && (settings.loop || $related[index + 1])) {
     1041        if (!active && $related[1] && (settings.get('loop') || $related[index + 1])) {
    9531042            index = getIndex(1);
    9541043            launch($related[index]);
    9551044        }
    9561045    };
    957    
     1046
    9581047    publicMethod.prev = function () {
    959         if (!active && $related[1] && (settings.loop || index)) {
     1048        if (!active && $related[1] && (settings.get('loop') || index)) {
    9601049            index = getIndex(-1);
    9611050            launch($related[index]);
     
    9661055    publicMethod.close = function () {
    9671056        if (open && !closing) {
    968            
     1057
    9691058            closing = true;
    970            
    9711059            open = false;
    972            
    973             trigger(event_cleanup, settings.onCleanup);
    974            
     1060            trigger(event_cleanup);
     1061            settings.get('onCleanup');
    9751062            $window.unbind('.' + prefix);
    976            
    977             $overlay.fadeTo(200, 0);
    978            
    979             $box.stop().fadeTo(300, 0, function () {
    980            
    981                 $box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
    982                
     1063            $overlay.fadeTo(settings.get('fadeOut') || 0, 0);
     1064
     1065            $box.stop().fadeTo(settings.get('fadeOut') || 0, 0, function () {
     1066                $box.hide();
     1067                $overlay.hide();
    9831068                trigger(event_purge);
    984                
    985                 $loaded.empty().remove(); // Using empty first may prevent some IE7 issues.
    986                
     1069                $loaded.remove();
     1070
    9871071                setTimeout(function () {
    9881072                    closing = false;
    989                     trigger(event_closed, settings.onClosed);
     1073                    trigger(event_closed);
     1074                    settings.get('onClosed');
    9901075                }, 1);
    9911076            });
     
    9981083
    9991084        $box.stop();
    1000         $.colorbox.close();
    1001         $box.stop().remove();
     1085        $[colorbox].close();
     1086        $box.stop(false, true).remove();
    10021087        $overlay.remove();
    10031088        closing = false;
     
    10071092            .removeClass(boxElement);
    10081093
    1009         $(document).unbind('click.'+prefix);
     1094        $(document).unbind('click.'+prefix).unbind('keydown.'+prefix);
    10101095    };
    10111096
     
    10131098    // returns a jQuery object.
    10141099    publicMethod.element = function () {
    1015         return $(element);
     1100        return $(settings.el);
    10161101    };
    10171102
  • wp-multitasking/trunk/readme.txt

    r2323405 r2964791  
    44Tags: shorcode,mark id,bbcode,welcome popup,exit popup,popup,addquicktag,custom post type,post type,remove base slug
    55Requires at least: 2.1.0
    6 Tested up to: 5.4.2
    7 Stable tag: 0.1.7
     6Tested up to: 6.3.1
     7Stable tag: 0.1.8
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1818* BBCode
    1919* Include custom post type for AddQuickTag plugin settings
    20 * Exit pop-up each per post, page
    21 * Welcome pop-up each per post, page
     20* Exit pop-up each per post, page and custom post type
     21* Welcome pop-up each per post, page and custom post type
    2222* Remove base slug from custom post type
     23* Replace the Block Editor with the Classic Editor
     24* Enables the classic widgets settings screens in Appearance - Widgets
     25* SMTP Settings
    2326
    2427== Installation ==
     
    4346
    4447= How To change menu name =
    45 * Go to 'wp-admin -> PPO WPMT -> PPO WPMT'
    46 * Enter the name you want
     48* Go to 'wp-admin -> WP Utilities -> WP Utilities'
     49* Enter the name you want to set
    4750
    4851= How To using BBCode =
     
    71741. WP MultiTasking settings
    72752. AddQuickTag settings
    73 3. Welcome popup settings.
    74 4. Exit popup settings.
     763. Welcome popup settings
     774. Exit popup settings
    75785. Remove base slug from custom post type
     796. SMTP Settings
    7680
    7781== Changelog ==
     82
     83= 0.1.8 =
     84* Audit custom permalinks
     85* Add Fancybox option for pop-up
     86* Add SMTP settings
    7887
    7988= 0.1.7 =
  • wp-multitasking/trunk/wp-multitasking.php

    r2323405 r2964791  
    11<?php
    22/***************************************************************************
    3 Plugin Name: WP MultiTasking - PPO Utilities
     3Plugin Name: WP MultiTasking - WP Utilities
    44Plugin URI:  http://wordpress.org/plugins/wp-multitasking/
    5 Description: This plugin is synthetic utility for your WordPress site
    6 Version:     0.1.7
     5Description: This plugin is synthetic utility for your WordPress site: Shortcode, BBCode, AddQuickTag, Exit pop-up, Welcome pop-up, Remove base slug, SMTP, Classic Editor, Classic widgets...
     6Version:     0.1.8
    77Author:      thangnv27
    8 Author URI:  https://ppo.vn/
     8Author URI:  https://ngothang.me/
    99**************************************************************************/
    1010
     
    1616
    1717if ( ! defined( 'WPMT_MENU_NAME' ) )
    18     define( 'WPMT_MENU_NAME', 'PPO Utilities' );
     18    define( 'WPMT_MENU_NAME', 'WP Utilities' );
    1919
    2020if ( ! defined( 'WPMT_MENU_ID' ) )
    2121    define( 'WPMT_MENU_ID', 'wpmt_settings' );
     22   
     23if ( ! defined( 'WPMT_VER' ) )
     24    define( 'WPMT_VER', '0.1.8' );
    2225
    2326add_action('admin_menu', 'wpmt_add_settings_page');
     
    2528function wpmt_add_settings_page(){
    2629    $menu_name = stripslashes(get_option('wpmt_menu_name'));
    27     if(empty($menu_name)){
    28         add_menu_page(WPMT_MENU_NAME, // Page title
    29                 WPMT_MENU_NAME, // Menu title
    30                 'manage_options', // Capability - see: http://codex.wordpress.org/Roles_and_Capabilities#Capabilities
    31                 WPMT_MENU_ID, // menu id - Unique id of the menu
    32                 'wpmt_display_settings_page',// render output function
    33                 '', // URL icon, if empty default icon
    34                 null // Menu position - integer, if null default last of menu list
    35             );
    36     }else{
    37         add_menu_page($menu_name, // Page title
    38                 $menu_name, // Menu title
    39                 'manage_options', // Capability - see: http://codex.wordpress.org/Roles_and_Capabilities#Capabilities
    40                 WPMT_MENU_ID, // menu id - Unique id of the menu
    41                 'wpmt_display_settings_page',// render output function
    42                 '', // URL icon, if empty default icon
    43                 null // Menu position - integer, if null default last of menu list
    44             );
    45     }
     30    $menu_name = (empty($menu_name)) ? WPMT_MENU_NAME : $menu_name;
     31    add_menu_page($menu_name, // Page title
     32        $menu_name, // Menu title
     33        'manage_options', // Capability - see: http://codex.wordpress.org/Roles_and_Capabilities#Capabilities
     34        WPMT_MENU_ID, // menu id - Unique id of the menu
     35        'wpmt_display_settings_page',// render output function
     36        '', // URL icon, if empty default icon
     37        null // Menu position - integer, if null default last of menu list
     38    );
    4639    /*-------------------------------------------------------------------------*/
    4740    # Update data
     
    4942    if (isset($_GET['page']) and $_GET['page'] == WPMT_MENU_ID) {
    5043        if (isset($_POST['action']) and 'save' == $_POST['action']) {
    51             if(isset($_POST["wpmt_menu_name"]) && !empty($_POST["wpmt_menu_name"])){
    52                 update_option("wpmt_menu_name", $_POST["wpmt_menu_name"]);
    53             }else{
    54                 delete_option("wpmt_menu_name");
     44            $fields = ['wpmt_menu_name', 'wpmt_classic_editor', 'wpmt_classic_widgets', 'wpmt_popup_type', 'wpmt_colorbox_type'];
     45            foreach ($fields as $field) {
     46                if (isset($_REQUEST[$field]) and !empty($_REQUEST[$field])) {
     47                    update_option($field, $_REQUEST[$field]);
     48                } else {
     49                    delete_option($field);
     50                }
    5551            }
     52
    5653            header("Location: {$_SERVER['REQUEST_URI']}&saved=true");
    5754            die();
    58         } 
     55        }
    5956    }
    6057}
    6158
    6259function wpmt_display_settings_page() {
     60    $popup_type = get_option('wpmt_popup_type');
     61    $colorbox_type = get_option('wpmt_colorbox_type');
     62    $colorbox_type = (!in_array($colorbox_type, [1,2,3,4,5])) ? 3 : $colorbox_type;
    6363?>
    6464    <div class="wrap">
     
    7777            ?>
    7878            <form method="post">
    79                 <table width="100%">
     79                <table class="form-table" width="100%">
    8080                    <tr>
    8181                        <td>
     
    8484                        <td>
    8585                            <input type="text" name="wpmt_menu_name" id="wpmt_menu_name" value="<?php echo stripslashes(get_option('wpmt_menu_name')); ?>" class="regular-text" />
     86                        </td>
     87                    </tr>
     88                    <tr>
     89                        <td>
     90                            <label for="wpmt_classic_editor">Classic Editor:</label>
     91                        </td>
     92                        <td>
     93                            <input type="checkbox" name="wpmt_classic_editor" id="wpmt_classic_editor" value="1"
     94                                <?php echo (get_option('wpmt_classic_editor') == '1') ? "checked" : ""; ?> />
     95                            <label for="wpmt_classic_editor">Replace the Block Editor with the Classic Editor</label>
     96                        </td>
     97                    </tr>
     98                    <tr>
     99                        <td>
     100                            <label for="wpmt_classic_widgets">Classic Widgets:</label>
     101                        </td>
     102                        <td>
     103                            <input type="checkbox" name="wpmt_classic_widgets" id="wpmt_classic_widgets" value="1"
     104                                <?php echo (get_option('wpmt_classic_widgets') == '1') ? "checked" : ""; ?> />
     105                            <label for="wpmt_classic_widgets">Enables the classic widgets settings screens in Appearance - Widgets</label>
     106                        </td>
     107                    </tr>
     108                    <tr>
     109                        <td>
     110                            <label for="wpmt_popup_type">Popup type:</label>
     111                        </td>
     112                        <td>
     113                            <input type="radio" name="wpmt_popup_type" id="wpmt_popup_type_colorbox" value="colorbox"
     114                                <?php echo ($popup_type !== 'fancybox') ? "checked" : ""; ?> />
     115                            <label for="wpmt_popup_type_colorbox">Colorbox</label>&nbsp;
     116                            <input type="radio" name="wpmt_popup_type" id="wpmt_popup_type_fancybox" value="fancybox"
     117                                <?php echo ($popup_type === 'fancybox') ? "checked" : ""; ?> />
     118                            <label for="wpmt_popup_type_fancybox">Fancybox</label>
     119                        </td>
     120                    </tr>
     121                    <tr>
     122                        <td>
     123                            <label for="wpmt_colorbox_type">Colorbox style:</label>
     124                        </td>
     125                        <td>
     126                            <select name="wpmt_colorbox_type" id="wpmt_colorbox_type" class="postform">
     127                                <?php for($i = 1; $i < 6; $i++): ?>
     128                                <option value="<?php echo $i; ?>" <?php echo ($colorbox_type == $i) ? "selected" : ""; ?>>Style <?php echo $i; ?></option>
     129                                <?php endfor; ?>
     130                            </select> <em>(Apply for Colorbox type)</em>
    86131                        </td>
    87132                    </tr>
     
    103148function wpmt_register_scripts(){
    104149    wp_enqueue_media();
    105    
    106     ## Register All Styles
    107     wp_register_style('wpmt-chosen-template', WPMT_PLUGIN_URL . 'css/chosen.min.css');
     150
    108151    ## Get Global Styles
    109     wp_enqueue_style('wpmt-chosen-template');
    110    
    111     ## Register All Scripts
    112     wp_register_script('wpmt-chosen', WPMT_PLUGIN_URL . 'js/chosen.jquery.min.js', array('jquery'));
     152    wp_enqueue_style('wpmt-chosen-template', WPMT_PLUGIN_URL . 'css/chosen.min.css', array(), '1.0.0');
     153
    113154    ## Get Global Scripts
    114     wp_enqueue_script('wpmt-chosen');
     155    wp_enqueue_script('wpmt-chosen', WPMT_PLUGIN_URL . 'js/chosen.jquery.min.js', array('jquery'), '1.0.0',  true);
    115156}
    116157
     
    133174
    134175require_once WPMT_PLUGIN_DIR . '/includes/bbcode.php';
     176require_once WPMT_PLUGIN_DIR . '/includes/classic-editor.php';
     177require_once WPMT_PLUGIN_DIR . '/includes/classic-widgets.php';
    135178require_once WPMT_PLUGIN_DIR . '/includes/shortcode_markid.php';
    136179require_once WPMT_PLUGIN_DIR . '/includes/addquicktag_cpt.php';
     
    139182require_once WPMT_PLUGIN_DIR . '/includes/floating-popup/exit-popup.php';
    140183require_once WPMT_PLUGIN_DIR . '/includes/floating-popup/global-popup.php';
     184require_once WPMT_PLUGIN_DIR . '/includes/smtp.php';
Note: See TracChangeset for help on using the changeset viewer.