Changeset 2964791
- Timestamp:
- 09/09/2023 03:15:27 PM (3 years ago)
- Location:
- wp-multitasking/trunk
- Files:
-
- 47 added
- 2 deleted
- 11 edited
-
includes/bbcode.php (modified) (3 diffs)
-
includes/classic-editor.php (added)
-
includes/classic-widgets.php (added)
-
includes/floating-popup/exit-popup.php (modified) (3 diffs)
-
includes/floating-popup/global-popup.php (modified) (2 diffs)
-
includes/floating-popup/welcome-popup.php (modified) (3 diffs)
-
includes/permalinks.php (modified) (2 diffs)
-
includes/smtp.php (added)
-
js/block-editor-plugin.js (added)
-
js/common.multitasking.js (modified) (2 diffs)
-
js/floating.popup.js (modified) (7 diffs)
-
libraries/colorbox/colorbox.css (deleted)
-
libraries/colorbox/example1 (added)
-
libraries/colorbox/example1/colorbox.css (added)
-
libraries/colorbox/example1/images (added)
-
libraries/colorbox/example1/images/border.png (added)
-
libraries/colorbox/example1/images/controls.png (added)
-
libraries/colorbox/example1/images/loading.gif (added)
-
libraries/colorbox/example1/images/loading_background.png (added)
-
libraries/colorbox/example1/images/overlay.png (added)
-
libraries/colorbox/example1/index.html (added)
-
libraries/colorbox/example2 (added)
-
libraries/colorbox/example2/colorbox.css (added)
-
libraries/colorbox/example2/images (added)
-
libraries/colorbox/example2/images/controls.png (added)
-
libraries/colorbox/example2/images/loading.gif (added)
-
libraries/colorbox/example2/index.html (added)
-
libraries/colorbox/example3 (added)
-
libraries/colorbox/example3/colorbox.css (added)
-
libraries/colorbox/example3/images (added)
-
libraries/colorbox/example3/images/controls.png (added)
-
libraries/colorbox/example3/images/loading.gif (added)
-
libraries/colorbox/example3/index.html (added)
-
libraries/colorbox/example4 (added)
-
libraries/colorbox/example4/colorbox.css (added)
-
libraries/colorbox/example4/images (added)
-
libraries/colorbox/example4/images/border1.png (added)
-
libraries/colorbox/example4/images/border2.png (added)
-
libraries/colorbox/example4/images/loading.gif (added)
-
libraries/colorbox/example4/index.html (added)
-
libraries/colorbox/example5 (added)
-
libraries/colorbox/example5/colorbox.css (added)
-
libraries/colorbox/example5/images (added)
-
libraries/colorbox/example5/images/border.png (added)
-
libraries/colorbox/example5/images/controls.png (added)
-
libraries/colorbox/example5/images/loading.gif (added)
-
libraries/colorbox/example5/images/loading_background.png (added)
-
libraries/colorbox/example5/index.html (added)
-
libraries/colorbox/images (deleted)
-
libraries/colorbox/jquery.colorbox-min.js (added)
-
libraries/colorbox/jquery.colorbox.js (modified) (35 diffs)
-
libraries/fancybox (added)
-
libraries/fancybox/jquery.fancybox.css (added)
-
libraries/fancybox/jquery.fancybox.js (added)
-
libraries/fancybox/jquery.fancybox.min.css (added)
-
libraries/fancybox/jquery.fancybox.min.js (added)
-
readme.txt (modified) (4 diffs)
-
screenshot-1.jpg (modified) (previous)
-
screenshot-6.jpg (added)
-
wp-multitasking.php (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-multitasking/trunk/includes/bbcode.php
r2323405 r2964791 6 6 */ 7 7 class WPMT_BBCode { 8 static $_s = null; 8 9 9 10 // Plugin initialization … … 50 51 } 51 52 53 public static function init() { 54 if (self::$_s == null) { 55 self::$_s = new self(); 56 } 57 return self::$_s; 58 } 59 52 60 // No-name attribute fixing 53 61 function attributefix($atts = array()) { … … 238 246 239 247 // 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();'));248 add_action( 'plugins_loaded', array( 'WPMT_BBCode', 'init' ) ); -
wp-multitasking/trunk/includes/floating-popup/exit-popup.php
r2323405 r2964791 507 507 } 508 508 function wpmt_exit_add_vars(){ 509 $popup_type = get_option('wpmt_popup_type'); 510 $popup_type = ($popup_type != 'fancybox') ? 'colorbox' : $popup_type; 509 511 $exit_popup_home = intval(get_option('exit_popup_home')); 510 512 $exit_pop_days = intval(get_option('default_exit_pop_days')); … … 544 546 echo <<<HTML 545 547 <script type="text/javascript"> 548 var exit_popup_type = '$popup_type'; 546 549 var exit_popup_cookieName = '$exit_popup_cookieName'; 547 550 var exit_popup_days = $exit_pop_days; … … 556 559 HTML; 557 560 } 558 } else if (is_home() ){561 } else if (is_home() or is_front_page()){ 559 562 if($exit_popup_home == 1){ 560 563 $exit_popup_cookieName = "exit_popup_home"; 561 564 echo <<<HTML 562 565 <script type="text/javascript"> 566 var exit_popup_type = '$popup_type'; 563 567 var exit_popup_cookieName = '$exit_popup_cookieName'; 564 568 var exit_popup_days = $exit_pop_days; -
wp-multitasking/trunk/includes/floating-popup/global-popup.php
r2323405 r2964791 8 8 function wpmt_popup_add_styles() { 9 9 $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; 10 13 11 14 if (is_single() or is_page()) { … … 14 17 $welcome_active = get_post_meta($post_id, 'wcome_active', true); 15 18 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" /> 18 22 HTML; 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" /> 26 HTML; 27 } 19 28 } 20 } else if (is_home() ) {29 } else if (is_home() or is_front_page()) { 21 30 $exit_popup_home = intval(get_option('exit_popup_home')); 22 31 $welcome_popup_home = intval(get_option('welcome_popup_home')); 23 32 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" /> 26 36 HTML; 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" /> 40 HTML; 41 } 27 42 } 28 43 } 29 44 } 45 30 46 function wpmt_popup_add_scripts(){ 47 $popup_type = get_option('wpmt_popup_type'); 31 48 if(is_single() or is_page()){ 32 49 $exit_active = get_post_meta(get_the_ID(), 'exit_active', true); 33 50 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); 37 58 } 38 }elseif (is_home() ) {59 }elseif (is_home() or is_front_page()) { 39 60 $exit_popup_home = intval(get_option('exit_popup_home')); 40 61 $welcome_popup_home = intval(get_option('welcome_popup_home')); 41 62 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); 45 70 } 46 71 } -
wp-multitasking/trunk/includes/floating-popup/welcome-popup.php
r2323405 r2964791 520 520 } 521 521 function wpmt_welcome_add_vars(){ 522 $popup_type = get_option('wpmt_popup_type'); 523 $popup_type = ($popup_type != 'fancybox') ? 'colorbox' : $popup_type; 522 524 $welcome_popup_home = intval(get_option('welcome_popup_home')); 523 525 $wcome_pop_days = intval(get_option('default_wcome_pop_days')); … … 559 561 echo <<<HTML 560 562 <script type="text/javascript"> 563 var welcome_popup_type = '$popup_type'; 561 564 var welcome_popup_cookieName = '$wcome_popup_cookieName'; 562 565 var welcome_popup_days = $wcome_pop_days; … … 572 575 HTML; 573 576 } 574 } else if (is_home() ){577 } else if (is_home() or is_front_page()){ 575 578 if($welcome_popup_home == 1){ 576 579 $wcome_popup_cookieName = "welcome_popup_home"; 577 580 echo <<<HTML 578 581 <script type="text/javascript"> 582 var welcome_popup_type = '$popup_type'; 579 583 var welcome_popup_cookieName = '$wcome_popup_cookieName'; 580 584 var welcome_popup_days = $wcome_pop_days; -
wp-multitasking/trunk/includes/permalinks.php
r837190 r2964791 38 38 //To link our submenu to a custom post type page we must specify - 39 39 //edit.php?post_type=my_post_type 40 __('Permalinks '), // Page title40 __('Permalinks Settings'), // Page title 41 41 __('Permalinks'), // Menu title 42 42 'manage_options', // Capability - see: http://codex.wordpress.org/Roles_and_Capabilities#Capabilities … … 172 172 } 173 173 } 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']; 181 180 } 182 181 } -
wp-multitasking/trunk/js/common.multitasking.js
r831023 r2964791 1 1 var WPMTFunc = { 2 setCookie: function(name, value, expires, path, domain, secure){2 setCookie: function(name, value, expires, path, domain, secure) { 3 3 var today = new Date(); 4 4 today.setTime(today.getTime()); 5 5 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" : ""); 12 7 }, 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) { 19 9 var start = document.cookie.indexOf(name + "="); 20 10 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))) { 23 12 return null; 24 13 } … … 28 17 return unescape(document.cookie.substring(len, end)); 29 18 }, 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 36 21 }, 37 addEvent: function(obj, eventName, func){38 if (obj.attachEvent) {22 addEvent: function(obj, eventName, func) { 23 if (obj.attachEvent) { 39 24 obj.attachEvent("on" + eventName, func); 40 } 41 else if(obj.addEventListener){ 25 } else if (obj.addEventListener) { 42 26 obj.addEventListener(eventName, func, true); 43 } 44 else{ 27 } else { 45 28 obj["on" + eventName] = func; 46 29 } 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); 47 62 } 48 63 }; -
wp-multitasking/trunk/js/floating.popup.js
r831023 r2964791 2 2 var WelcomePopup = { 3 3 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 } 4 9 if(welcome_popup_embed == 0){ 5 10 $.ajax({ … … 17 22 } 18 23 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 { 19 94 $.colorbox({ 20 95 html: response, … … 25 100 fixed: true 26 101 }); 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 } 67 103 }, welcome_popup_delays * 1000); 68 104 }, … … 111 147 }, 112 148 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 } 113 154 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 { 114 169 $.colorbox({ 115 170 iframe: true, … … 121 176 fixed: true 122 177 }); 178 } 123 179 } else if(exit_popup_embed == 0 || exit_popup_embed == 2){ 124 180 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 { 125 188 $.colorbox({ 126 189 html: exit_content, … … 131 194 fixed: true 132 195 }); 196 } 133 197 } 134 198 } … … 137 201 jQuery(function($){ 138 202 $(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 139 216 WelcomePopup.show($); 140 217 if(!WPMTFunc.getCookie(welcome_popup_cookieName)){ 141 ExitPopup.setup($);142 218 WPMTFunc.setCookie(welcome_popup_cookieName, welcome_popup_days, 1 * 24*60*60*1000, '/', '', ''); 143 219 }else if(WPMTFunc.getCookie(welcome_popup_cookieName) != welcome_popup_days){ 144 220 WPMTFunc.setCookie(welcome_popup_cookieName, welcome_popup_days, 1 * 24*60*60*1000, '/', '', ''); 145 221 } 146 $(document).mousemove(function(e) {147 if(e.pageY <= 10 && $("#cboxOverlay").is(":hidden")) {148 ExitPopup.show($);149 }150 });151 222 }); 152 223 }); -
wp-multitasking/trunk/libraries/colorbox/jquery.colorbox.js
r831023 r2964791 1 1 /*! 2 jQuery Colorbox v1.4.10 - 2013-04-023 (c) 2013 Jack Moore - jacklmoore.com/colorbox4 license: http://www.opensource.org/licenses/mit-license.php2 Colorbox 1.6.4 3 license: MIT 4 http://www.jacklmoore.com/colorbox 5 5 */ 6 6 (function ($, document, window) { … … 9 9 // See http://jacklmoore.com/colorbox for details. 10 10 defaults = { 11 // data sources 12 html: false, 13 photo: false, 14 iframe: false, 15 inline: false, 16 17 // behavior and appearance 11 18 transition: "elastic", 12 19 speed: 300, 20 fadeOut: 300, 13 21 width: false, 14 22 initialWidth: "600", … … 21 29 scalePhotos: true, 22 30 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,31 31 opacity: 0.9, 32 32 preloading: true, 33 33 className: false, 34 35 // alternate image paths for high-res displays36 retinaImage: false,37 retinaUrl: false,38 retinaSuffix: '@2x.$1',39 40 // internationalization41 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,64 34 overlayClose: true, 65 35 escKey: true, … … 70 40 right: false, 71 41 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 } 73 122 }, 74 123 75 124 // Abstracting the HTML and event identifiers for easy rebranding 76 125 colorbox = 'colorbox', 77 126 prefix = 'cbox', 78 127 boxElement = prefix + 'Element', 79 128 80 129 // Events 81 130 event_open = prefix + '_open', … … 107 156 $close, 108 157 $groupControls, 109 $events = $('<a/>'), 110 158 $events = $('<a/>'), // $({}) would be preferred, but there is an issue with jQuery 1.4.2 159 111 160 // Variables for cached values or use across multiple functions 112 161 settings, … … 115 164 loadedHeight, 116 165 loadedWidth, 117 element,118 166 index, 119 167 photo, … … 124 172 publicMethod, 125 173 div = "div", 126 className,127 174 requests = 0, 175 previousCSS = {}, 128 176 init; 129 177 … … 131 179 // HELPER FUNCTIONS 132 180 // **************** 133 134 // Conv ience function for creating new jQuery objects181 182 // Convenience function for creating new jQuery objects 135 183 function $tag(tag, id, css) { 136 184 var element = document.createElement(tag); … … 146 194 return $(element); 147 195 } 148 196 149 197 // Get the window height using innerHeight when available to avoid an issue with iOS 150 198 // http://bugs.jquery.com/ticket/6724 151 199 function winheight() { 152 200 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 }; 153 233 } 154 234 … … 158 238 max = $related.length, 159 239 newIndex = (index + increment) % max; 160 240 161 241 return (newIndex < 0) ? max + newIndex : newIndex; 162 242 } … … 166 246 return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10)); 167 247 } 168 248 169 249 // Checks an href to see if it is a photo. 170 250 // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex. 171 251 function isImage(settings, url) { 172 return settings. photo || settings.photoRegex.test(url);252 return settings.get('photo') || settings.get('photoRegex').test(url); 173 253 } 174 254 175 255 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; 177 257 } 178 258 179 259 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]) { 181 261 e.stopPropagation(); 182 262 $box.focus(); … … 184 264 } 185 265 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; 195 288 } 196 289 } 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) { 216 295 // for external use 217 296 $(document).trigger(event); 218 219 297 // 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]) { 264 313 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')) { 276 370 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 293 385 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')); 339 392 340 393 if (!open) { 341 394 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 343 398 // 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); 347 403 348 404 // Cache values needed for size calculations … … 351 407 loadedHeight = $loaded.outerHeight(true); 352 408 loadedWidth = $loaded.outerWidth(true); 353 354 409 355 410 // 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}); 358 420 publicMethod.position(); 359 421 360 slideshow(); 361 362 trigger(event_open, settings.onOpen); 363 422 trigger(event_open); 423 settings.get('onOpen'); 424 364 425 $groupControls.add($title).hide(); 365 426 366 427 $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')) { 374 444 $events.one(event_closed, function () { 375 document.removeEventListener('focus', trapFocus, true);445 $(settings.el).focus(); 376 446 }); 377 447 } 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 387 463 load(); 388 464 } … … 392 468 // so that the browser will go ahead and load the CSS background images. 393 469 function appendHTML() { 394 if (!$box && document.body) {470 if (!$box) { 395 471 init = false; 396 472 $window = $(window); … … 402 478 }).hide(); 403 479 $overlay = $tag(div, "Overlay").hide(); 404 $loadingOverlay = $ tag(div, "LoadingOverlay").add($tag(div, "LoadingGraphic"));480 $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]); 405 481 $wrap = $tag(div, "Wrapper"); 406 482 $content = $tag(div, "Content").append( 407 483 $title = $tag(div, "Title"), 408 484 $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 414 489 ); 415 490 491 $close = $('<button type="button"/>').attr({id:prefix+'Close'}); 492 416 493 $wrap.append( // The 3x3 Grid that makes up Colorbox 417 494 $tag(div).append( … … 431 508 ) 432 509 ).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 436 513 $groupControls = $next.add($prev).add($current).add($slideshow); 437 514 } 515 if (document.body && !$box.parent().length) { 438 516 $(document.body).append($overlay, $box.append($wrap, $loadingBay)); 439 517 } … … 445 523 // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt. 446 524 // See: http://jacklmoore.com/notes/click-events/ 447 if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.c ontrol)) {525 if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) { 448 526 e.preventDefault(); 449 527 launch(this); … … 466 544 }); 467 545 $overlay.click(function () { 468 if (settings. overlayClose) {546 if (settings.get('overlayClose')) { 469 547 publicMethod.close(); 470 548 } 471 549 }); 472 550 473 551 // Key Bindings 474 552 $(document).bind('keydown.' + prefix, function (e) { 475 553 var key = e.keyCode; 476 if (open && settings. escKey&& key === 27) {554 if (open && settings.get('escKey') && key === 27) { 477 555 e.preventDefault(); 478 556 publicMethod.close(); 479 557 } 480 if (open && settings. arrowKey&& $related[1] && !e.altKey) {558 if (open && settings.get('arrowKey') && $related[1] && !e.altKey) { 481 559 if (key === 37) { 482 560 e.preventDefault(); … … 505 583 506 584 // Don't do anything if Colorbox already exists. 507 if ($ .colorbox) {585 if ($[colorbox]) { 508 586 return; 509 587 } … … 518 596 // Usage from within an iframe: parent.jQuery.colorbox.close(); 519 597 // **************** 520 598 521 599 publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) { 522 var $this = this; 523 600 var settings; 601 var $obj = this; 602 524 603 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 526 614 appendHTML(); 527 615 528 616 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 536 618 if (callback) { 537 619 options.onComplete = callback; 538 620 } 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)); 542 625 }).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; 550 635 }; 551 636 … … 558 643 scrollTop, 559 644 scrollLeft; 560 645 561 646 $window.unbind('resize.' + prefix); 562 647 … … 567 652 scrollLeft = $window.scrollLeft(); 568 653 569 if (settings. fixed) {654 if (settings.get('fixed')) { 570 655 offset.top -= scrollTop; 571 656 offset.left -= scrollLeft; … … 578 663 579 664 // 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'); 584 669 } else { 585 670 left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2); 586 671 } 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'); 592 677 } else { 593 678 top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2); … … 596 681 $box.css({top: offset.top, left: offset.left, visibility:'visible'}); 597 682 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 601 683 // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly, 602 684 // but it has to be shrank down around the size of div#colorbox when it's done. If not, 603 685 // it can invoke an obscure IE bug when using iframes. 604 686 $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'; 609 691 } 610 692 611 693 css = {width: settings.w + loadedWidth + interfaceWidth, height: settings.h + loadedHeight + interfaceHeight, top: top, left: left}; 612 694 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) { 614 710 $box.css(css); 615 711 } 712 616 713 $box.dequeue().animate(css, { 617 duration: speed ,714 duration: speed || 0, 618 715 complete: function () { 619 modalDimensions( this);620 716 modalDimensions(); 717 621 718 active = false; 622 719 623 720 // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation. 624 721 $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px"; 625 722 $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px"; 626 627 if (settings. reposition) {723 724 if (settings.get('reposition')) { 628 725 setTimeout(function () { // small delay before binding onresize due to an IE8 bug. 629 726 $window.bind('resize.' + prefix, publicMethod.position); … … 631 728 } 632 729 633 if ( loadedCallback) {730 if ($.isFunction(loadedCallback)) { 634 731 loadedCallback(); 635 732 } 636 733 }, 637 step: function () { 638 modalDimensions(this); 639 } 734 step: modalDimensions 640 735 }); 641 736 }; 642 737 643 738 publicMethod.resize = function (options) { 739 var scrolltop; 740 644 741 if (open) { 645 742 options = options || {}; 646 743 647 744 if (options.width) { 648 745 settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth; 649 746 } 747 650 748 if (options.innerWidth) { 651 749 settings.w = setSize(options.innerWidth, 'x'); 652 750 } 751 653 752 $loaded.css({width: settings.w}); 654 753 655 754 if (options.height) { 656 755 settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight; 657 756 } 757 658 758 if (options.innerHeight) { 659 759 settings.h = setSize(options.innerHeight, 'y'); 660 760 } 761 661 762 if (!options.innerHeight && !options.height) { 763 scrolltop = $loaded.scrollTop(); 662 764 $loaded.css({height: "auto"}); 663 765 settings.h = $loaded.height(); 664 766 } 767 665 768 $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')); 668 775 } 669 776 }; … … 673 780 return; 674 781 } 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(); 679 786 680 787 $loaded = $tag(div, 'LoadedContent').append(object); 681 788 682 789 function getWidth() { 683 790 settings.w = settings.w || $loaded.width(); … … 690 797 return settings.h; 691 798 } 692 799 693 800 $loaded.hide() 694 801 .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'}) 696 803 .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height. 697 804 .prependTo($content); 698 805 699 806 $loadingBay.hide(); 700 807 701 808 // 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 703 810 $(photo).css({'float': 'none'}); 811 812 setClass(settings.get('className')); 704 813 705 814 callback = function () { 706 815 var total = $related.length, 707 816 iframe, 708 frameBorder = 'frameBorder',709 allowTransparency = 'allowTransparency',710 817 complete; 711 818 712 819 if (!open) { 713 820 return; 714 821 } 715 716 function removeFilter() { // Needed for IE 7 & IE8 in versions of jQuery prior to 1.7.2822 823 function removeFilter() { // Needed for IE8 in versions of jQuery prior to 1.7.2 717 824 if ($.support.opacity === false) { 718 825 $box[0].style.removeAttribute('filter'); 719 826 } 720 827 } 721 828 722 829 complete = function () { 723 830 clearTimeout(loadingTimer); 724 831 $loadingOverlay.hide(); 725 trigger(event_complete, settings.onComplete); 832 trigger(event_complete); 833 settings.get('onComplete'); 726 834 }; 727 835 728 729 $title.html(settings.title).add($loaded).show(); 730 836 837 $title.html(settings.get('title')).show(); 838 $loaded.show(); 839 731 840 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 743 850 // Preloads images within a rel group 744 if (settings. preloading) {851 if (settings.get('preloading')) { 745 852 $.each([getIndex(-1), getIndex(1)], function(){ 746 var src, 747 img, 853 var img, 748 854 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'); 763 861 img.src = src; 764 862 } … … 768 866 $groupControls.hide(); 769 867 } 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')) { 783 874 iframe.scrolling = "no"; 784 875 } 785 876 786 877 $(iframe) 787 878 .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' 794 881 }) 795 882 .one('load', complete) 796 883 .appendTo($loaded); 797 884 798 885 $events.one(event_purge, function () { 799 886 iframe.src = "//about:blank"; 800 887 }); 801 888 802 if (settings. fastIframe) {889 if (settings.get('fastIframe')) { 803 890 $(iframe).trigger('load'); 804 891 } … … 806 893 complete(); 807 894 } 808 809 if (settings. transition=== 'fade') {895 896 if (settings.get('transition') === 'fade') { 810 897 $box.fadeTo(speed, 1, removeFilter); 811 898 } else { … … 813 900 } 814 901 }; 815 816 if (settings. transition=== 'fade') {902 903 if (settings.get('transition') === 'fade') { 817 904 $box.fadeTo(speed, 0, function () { 818 905 publicMethod.position(0, callback); … … 825 912 function load () { 826 913 var href, setResize, prep = publicMethod.prep, $inline, request = ++requests; 827 914 828 915 active = true; 829 916 830 917 photo = false; 831 832 element = $related[index]; 833 834 makeSettings(); 835 918 836 919 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 848 931 // Sets the minimum dimensions for use in image scaling 849 932 settings.mw = settings.w; 850 933 settings.mh = settings.h; 851 934 852 935 // Re-evaluate the minimum width and height based on maxWidth and maxHeight values. 853 936 // 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; 856 939 settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw; 857 940 } 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; 860 943 settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh; 861 944 } 862 863 href = settings. href;864 945 946 href = settings.get('href'); 947 865 948 loadingTimer = setTimeout(function () { 866 949 $loadingOverlay.show(); 867 950 }, 100); 868 869 if (settings.inline) { 951 952 if (settings.get('inline')) { 953 var $target = $(href).eq(0); 870 954 // Inserts an empty placeholder where inline content is being pulled from. 871 955 // 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); 873 957 874 958 $events.one(event_purge, function () { 875 $inline.replaceWith($ loaded.children());959 $inline.replaceWith($target); 876 960 }); 877 961 878 prep($ (href));879 } else if (settings. iframe) {962 prep($target); 963 } else if (settings.get('iframe')) { 880 964 // IFrame element won't be added to the DOM until it is ready to be displayed, 881 965 // to avoid problems with DOM-ready JS that might be trying to run in that iframe. 882 966 prep(" "); 883 } else if (settings. html) {884 prep(settings. html);967 } else if (settings.get('html')) { 968 prep(settings.get('html')); 885 969 } else if (isImage(settings, href)) { 886 970 887 971 href = retinaUrl(settings, href); 888 972 889 $(photo = new Image()) 973 photo = settings.get('createImg'); 974 975 $(photo) 890 976 .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'))); 894 979 }) 895 980 .one('load', function () { 896 var percent;897 898 981 if (request !== requests) { 899 982 return; 900 983 } 901 984 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; 915 993 } 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 } 919 1008 } 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'; 934 1024 prep(photo); 935 1025 }, 1); 936 1026 }); 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 941 1030 } else if (href) { 942 $loadingBay.load(href, settings. data, function (data, status) {1031 $loadingBay.load(href, settings.get('data'), function (data, status) { 943 1032 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()); 945 1034 } 946 1035 }); 947 1036 } 948 1037 } 949 1038 950 1039 // Navigates to the next page/image in a set. 951 1040 publicMethod.next = function () { 952 if (!active && $related[1] && (settings. loop|| $related[index + 1])) {1041 if (!active && $related[1] && (settings.get('loop') || $related[index + 1])) { 953 1042 index = getIndex(1); 954 1043 launch($related[index]); 955 1044 } 956 1045 }; 957 1046 958 1047 publicMethod.prev = function () { 959 if (!active && $related[1] && (settings. loop|| index)) {1048 if (!active && $related[1] && (settings.get('loop') || index)) { 960 1049 index = getIndex(-1); 961 1050 launch($related[index]); … … 966 1055 publicMethod.close = function () { 967 1056 if (open && !closing) { 968 1057 969 1058 closing = true; 970 971 1059 open = false; 972 973 trigger(event_cleanup, settings.onCleanup); 974 1060 trigger(event_cleanup); 1061 settings.get('onCleanup'); 975 1062 $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(); 983 1068 trigger(event_purge); 984 985 $loaded.empty().remove(); // Using empty first may prevent some IE7 issues. 986 1069 $loaded.remove(); 1070 987 1071 setTimeout(function () { 988 1072 closing = false; 989 trigger(event_closed, settings.onClosed); 1073 trigger(event_closed); 1074 settings.get('onClosed'); 990 1075 }, 1); 991 1076 }); … … 998 1083 999 1084 $box.stop(); 1000 $ .colorbox.close();1001 $box.stop( ).remove();1085 $[colorbox].close(); 1086 $box.stop(false, true).remove(); 1002 1087 $overlay.remove(); 1003 1088 closing = false; … … 1007 1092 .removeClass(boxElement); 1008 1093 1009 $(document).unbind('click.'+prefix) ;1094 $(document).unbind('click.'+prefix).unbind('keydown.'+prefix); 1010 1095 }; 1011 1096 … … 1013 1098 // returns a jQuery object. 1014 1099 publicMethod.element = function () { 1015 return $( element);1100 return $(settings.el); 1016 1101 }; 1017 1102 -
wp-multitasking/trunk/readme.txt
r2323405 r2964791 4 4 Tags: shorcode,mark id,bbcode,welcome popup,exit popup,popup,addquicktag,custom post type,post type,remove base slug 5 5 Requires at least: 2.1.0 6 Tested up to: 5.4.27 Stable tag: 0.1. 76 Tested up to: 6.3.1 7 Stable tag: 0.1.8 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 18 18 * BBCode 19 19 * 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 22 22 * 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 23 26 24 27 == Installation == … … 43 46 44 47 = 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 47 50 48 51 = How To using BBCode = … … 71 74 1. WP MultiTasking settings 72 75 2. AddQuickTag settings 73 3. Welcome popup settings .74 4. Exit popup settings .76 3. Welcome popup settings 77 4. Exit popup settings 75 78 5. Remove base slug from custom post type 79 6. SMTP Settings 76 80 77 81 == Changelog == 82 83 = 0.1.8 = 84 * Audit custom permalinks 85 * Add Fancybox option for pop-up 86 * Add SMTP settings 78 87 79 88 = 0.1.7 = -
wp-multitasking/trunk/wp-multitasking.php
r2323405 r2964791 1 1 <?php 2 2 /*************************************************************************** 3 Plugin Name: WP MultiTasking - PPOUtilities3 Plugin Name: WP MultiTasking - WP Utilities 4 4 Plugin URI: http://wordpress.org/plugins/wp-multitasking/ 5 Description: This plugin is synthetic utility for your WordPress site 6 Version: 0.1. 75 Description: 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... 6 Version: 0.1.8 7 7 Author: thangnv27 8 Author URI: https:// ppo.vn/8 Author URI: https://ngothang.me/ 9 9 **************************************************************************/ 10 10 … … 16 16 17 17 if ( ! defined( 'WPMT_MENU_NAME' ) ) 18 define( 'WPMT_MENU_NAME', ' PPOUtilities' );18 define( 'WPMT_MENU_NAME', 'WP Utilities' ); 19 19 20 20 if ( ! defined( 'WPMT_MENU_ID' ) ) 21 21 define( 'WPMT_MENU_ID', 'wpmt_settings' ); 22 23 if ( ! defined( 'WPMT_VER' ) ) 24 define( 'WPMT_VER', '0.1.8' ); 22 25 23 26 add_action('admin_menu', 'wpmt_add_settings_page'); … … 25 28 function wpmt_add_settings_page(){ 26 29 $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 ); 46 39 /*-------------------------------------------------------------------------*/ 47 40 # Update data … … 49 42 if (isset($_GET['page']) and $_GET['page'] == WPMT_MENU_ID) { 50 43 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 } 55 51 } 52 56 53 header("Location: {$_SERVER['REQUEST_URI']}&saved=true"); 57 54 die(); 58 } 55 } 59 56 } 60 57 } 61 58 62 59 function 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; 63 63 ?> 64 64 <div class="wrap"> … … 77 77 ?> 78 78 <form method="post"> 79 <table width="100%">79 <table class="form-table" width="100%"> 80 80 <tr> 81 81 <td> … … 84 84 <td> 85 85 <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> 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> 86 131 </td> 87 132 </tr> … … 103 148 function wpmt_register_scripts(){ 104 149 wp_enqueue_media(); 105 106 ## Register All Styles 107 wp_register_style('wpmt-chosen-template', WPMT_PLUGIN_URL . 'css/chosen.min.css'); 150 108 151 ## 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 113 154 ## 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); 115 156 } 116 157 … … 133 174 134 175 require_once WPMT_PLUGIN_DIR . '/includes/bbcode.php'; 176 require_once WPMT_PLUGIN_DIR . '/includes/classic-editor.php'; 177 require_once WPMT_PLUGIN_DIR . '/includes/classic-widgets.php'; 135 178 require_once WPMT_PLUGIN_DIR . '/includes/shortcode_markid.php'; 136 179 require_once WPMT_PLUGIN_DIR . '/includes/addquicktag_cpt.php'; … … 139 182 require_once WPMT_PLUGIN_DIR . '/includes/floating-popup/exit-popup.php'; 140 183 require_once WPMT_PLUGIN_DIR . '/includes/floating-popup/global-popup.php'; 184 require_once WPMT_PLUGIN_DIR . '/includes/smtp.php';
Note: See TracChangeset
for help on using the changeset viewer.