Changeset 2291595
- Timestamp:
- 04/25/2020 02:09:01 PM (6 years ago)
- Location:
- responsive-sidebar/trunk
- Files:
-
- 6 edited
-
readme.txt (modified) (2 diffs)
-
responsive-sidebar.php (modified) (1 diff)
-
src/Admin/Settings.php (modified) (2 diffs)
-
src/Frontend/Frontend.php (modified) (8 diffs)
-
src/ResponsiveSidebarPlugin.php (modified) (2 diffs)
-
views/admin/section/main-settings.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
responsive-sidebar/trunk/readme.txt
r2290403 r2291595 5 5 Requires at least: 5.0.3 6 6 Tested up to: 5.4 7 Stable tag: 1. 1.17 Stable tag: 1.2.0 8 8 Requires PHP: 5.6 9 9 License: GPLv2 or later … … 39 39 == Changelog == 40 40 41 = 1.2.0 = 42 Release Date: Apr 25, 2020 43 44 * Support for multiple sidebars 45 46 41 47 = 1.1.1 = 42 48 Release Date: Apr 23, 2020 -
responsive-sidebar/trunk/responsive-sidebar.php
r2290403 r2291595 8 8 * Plugin URI: https://processby.com/responsive-sidebar-wordpress-plugin/ 9 9 * Description: Makes your sidebar responsive. 10 * Version: 1. 1.110 * Version: 1.2.0 11 11 * Author: Processby 12 12 * Author URI: https://processby.com -
responsive-sidebar/trunk/src/Admin/Settings.php
r2030422 r2291595 49 49 'maxWidth' => $this->getOption('maxWidth'), 50 50 'sidebarSwipe' => $this->getOption('sidebarSwipe'), 51 'sidebars' => $this->getOption('sidebars') 51 52 )); 52 53 } … … 69 70 public function updateSettings($settings) 70 71 { 72 //dump($settings); die; 71 73 if(!isset($settings['sidebarSwipe'])) 72 74 $settings['sidebarSwipe'] = 0; 75 76 if(!isset($settings['sidebars'])) 77 $settings['sidebars'] = array(); 73 78 74 79 -
responsive-sidebar/trunk/src/Frontend/Frontend.php
r2290403 r2291595 60 60 add_action('wp_footer', array($this, 'addButtonHtml')); 61 61 add_action('wp_footer', array($this, 'addInlineScript')); 62 63 } 62 add_action( 'dynamic_sidebar_before', array($this, 'SidebarWrapBefore'), 10, 2 ); 63 add_action( 'dynamic_sidebar_after', array($this, 'SidebarWrapAfter'), 10, 2 ); 64 65 } 66 67 public function SidebarWrapBefore($index, $has_widgets) 68 { 69 70 foreach ($this->options['sidebars'] as $sidebarId){ 71 if( is_active_sidebar( $sidebarId ) && $index == $sidebarId){ 72 echo '<div class="resp-sidebar-wrapper">'; 73 } 74 } 75 76 77 } 78 79 public function SidebarWrapAfter($index, $has_widgets) 80 { 81 82 foreach ($this->options['sidebars'] as $sidebarId){ 83 if( is_active_sidebar( $sidebarId ) && $index == $sidebarId){ 84 echo '</div>'; 85 } 86 } 87 88 89 } 90 64 91 65 92 public function enqueueScripts() 66 93 { 67 68 94 69 95 } … … 108 134 $hiddenWidth = -$this->settings['sidebarWidth']-10; 109 135 110 $styles = "<style> 111 @media screen and (max-width: {$this->options['maxWidth']}px){ 112 #{$this->options['cssClasses']} { 136 137 $styles = "<style> @media screen and (max-width: {$this->options['maxWidth']}px){"; 138 139 140 if(!empty($this->options['sidebars'])){ 141 $styles .= ".resp-sidebar-wrapper{ 113 142 display: block; 114 143 position: fixed; … … 124 153 transition-duration: 0.5s; 125 154 transition-property: left; 126 } 127 } 128 #{$this->options['cssClasses']}.opened { 155 }"; 156 } elseif(!empty($this->options['cssClasses'])){ 157 $styles .= "#{$this->options['cssClasses']}{ 158 display: block; 159 position: fixed; 160 top: 0; 161 bottom: -100px; 162 left: {$hiddenWidth}px; 163 width: {$this->settings['sidebarWidth']}px; 164 overflow: auto; 165 z-index: 9999; 166 background: {$this->settings['sidebarBackground']}; 167 $sidebarShadows; 168 padding-bottom: 100px; 169 transition-duration: 0.5s; 170 transition-property: left; 171 }"; 172 } 173 174 175 $styles .= " 176 } 177 .resp-sidebar-wrapper.opened { 129 178 left: 0; 130 179 }"; 180 181 if(!empty($this->options['cssClasses'])){ 182 $styles .= "#{$this->options['cssClasses']}.opened { 183 left: 0; 184 }"; 185 } 186 131 187 132 188 if ($this->settings['enableButton']) { … … 192 248 public function addInlineScript() 193 249 { 194 250 if(!empty($this->options['sidebars'])){ 251 252 } 195 253 $ResponsiveSidebarScript = "<script type='text/javascript'> 196 254 197 var wr = document.getElementById('{$this->options['cssClasses']}'); 198 var btn = document.getElementById('responsive-sidebar-btn'); 255 var wrId = document.getElementById('{$this->options['cssClasses']}'); 256 var wr = document.getElementsByClassName('resp-sidebar-wrapper'); 257 "; 258 259 260 $ResponsiveSidebarScript .= "var btn = document.getElementById('responsive-sidebar-btn'); 199 261 var openedClass = 'opened'; 200 262 201 if(wr != null){263 if(wrId != null || wr.length != 0){ 202 264 btn.style.cssText = ''; 203 265 } … … 212 274 213 275 function openMobileSidebar() { 214 wr.classList.add(openedClass); 276 277 if(wrId != null){ 278 wrId.classList.add(openedClass); 279 } 280 if(wr.length != 0){ 281 wr[0].classList.add(openedClass); 282 } 215 283 btn.classList.add(openedClass); 216 284 217 285 } 218 286 function closeMobileSidebar() { 219 wr.classList.remove(openedClass); 287 if(wrId != null){ 288 wrId.classList.remove(openedClass); 289 } 290 if(wr.length != 0){ 291 wr[0].classList.remove(openedClass); 292 } 220 293 btn.classList.remove(openedClass); 221 }"; 294 } 295 296 function findAncestor (el, cls) { 297 while ((el = el.parentElement) && !el.classList.contains(cls)); 298 return el; 299 } 300 "; 301 302 222 303 223 304 if ($this->options['sidebarSwipe']) { 305 224 306 $ResponsiveSidebarScript .= " 225 307 var touchstartX = 0; … … 227 309 var touchendX = 0; 228 310 var touchendY = 0; 229 var deltaY = 45;311 var deltaY = 60; 230 312 var deltaX = 10; 231 313 var isSwiped; … … 235 317 touchstartX = event.changedTouches[0].screenX; 236 318 touchstartY = event.changedTouches[0].screenY; 237 event.path.forEach(function(element) {238 if(element.classList.contains('widget_price_filter')){239 isSwiped = false;240 }241 });319 320 if(findAncestor (event.target, 'widget_price_filter') != null){ 321 isSwiped = false; 322 }; 323 242 324 243 325 }, false); … … 256 338 if (touchendX < touchstartX && distanceY <= deltaY && distanceX >= deltaX) { 257 339 if(isSwiped){ 258 wr.classList.remove(openedClass); 259 btn.classList.remove(openedClass); 340 closeMobileSidebar(); 260 341 } 261 342 } 262 if (touchendX > touchstartX && distanceY <= deltaY && distanceX >= deltaX) { 263 if(isSwiped){264 wr.classList.add(openedClass);265 btn.classList.add(openedClass);266 }343 if (touchendX > touchstartX && distanceY <= deltaY && distanceX >= deltaX) { 344 345 if(isSwiped && touchstartX < 40){ 346 openMobileSidebar(); 347 } 267 348 } 268 349 }"; -
responsive-sidebar/trunk/src/ResponsiveSidebarPlugin.php
r2290403 r2291595 14 14 class ResponsiveSidebarPlugin { 15 15 16 const VERSION = '1. 1.1';16 const VERSION = '1.2.0'; 17 17 18 18 /** … … 64 64 $options['maxWidth'] = Settings::MAX_WIDTH; 65 65 $options['sidebarSwipe'] = Settings::SIDEBAR_SWIPE; 66 $options['sidebars'] = array(); 66 67 update_option(Settings::OPTIONS, $options); 67 68 } -
responsive-sidebar/trunk/views/admin/section/main-settings.php
r2032048 r2291595 6 6 7 7 use ResponsiveSidebar\Admin\Settings; 8 9 10 $sidebarsWidgets = wp_get_sidebars_widgets(); 11 global $wp_registered_sidebars; 12 8 13 9 14 echo '<h3>'.__('Appearance settings', 'responsive-sidebar').' <a href="' . … … 26 31 27 32 <tr> 28 <th scope="row"><?php _e('Responsive sidebar id','responsive-sidebar') ?></th> 33 <th scope="row"><?php _e('Select a sidebar','responsive-sidebar') ?></th> 34 <td> 35 <?php 36 37 foreach ($sidebarsWidgets as $key => $sidebar) { 38 if(!empty($sidebar) && $key != 'wp_inactive_widgets'){ ?> 39 <label> 40 <input type="checkbox" name="<?php echo Settings::OPTIONS; ?>[sidebars][]" value="<?= $key; ?>" <?= array_search($key, $sidebars) !== false?'checked':''; ?>> 41 <?= $wp_registered_sidebars[$key]['name']; ?> 42 </label><br> 43 <p><?= $wp_registered_sidebars[$key]['description']; ?></p><br> 44 <?php } 45 46 } 47 ?> 48 </td> 49 </tr> 50 51 <tr> 52 <th scope="row"><?php _e('Or enter the ID of the sidebar','responsive-sidebar') ?></th> 29 53 <td> 30 54 <input type="text" name="<?=Settings::OPTIONS?>[cssClasses]" size="26" value="<?php echo esc_attr( $cssClasses ) ?>" />
Note: See TracChangeset
for help on using the changeset viewer.