Changeset 2998159
- Timestamp:
- 11/18/2023 09:11:14 PM (2 years ago)
- Location:
- add-whatsapp-button/trunk
- Files:
-
- 1 added
- 7 edited
-
add-whatsapp-button.php (modified) (1 diff)
-
admin/settings.php (modified) (1 diff)
-
img/drag-horizontal.svg (added)
-
includes/scripts-manager.php (modified) (3 diffs)
-
includes/style-templates/frontend-css.php (modified) (1 diff)
-
js/wab.js (modified) (1 diff)
-
plugin.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
add-whatsapp-button/trunk/add-whatsapp-button.php
r2997916 r2998159 6 6 Text Domain: add-whatsapp-button 7 7 Domain Path: /languages 8 Version: 2.1. 18 Version: 2.1.2 9 9 Author URI: http://udidollberg.com/ 10 10 */ -
add-whatsapp-button/trunk/admin/settings.php
r2672423 r2998159 264 264 </tr> 265 265 <tr> 266 <th scope="row"><label for="awb_settings[enable_dragging]"><?php echo esc_html__( 'Allow dragging button on Y axis', 'add-whatsapp-button' ); ?></label></th> 267 <td> 268 <input name="awb_settings[enable_dragging]" type="checkbox" id="awb_settings[enable_dragging]" value="1" <?php isset($settings['enable_dragging'] ) ? checked('1', $settings['enable_dragging'] ) : ''; ?>> 269 <p class="description"><?php echo esc_html__( 'Check this box in order to add a small "dragging" handle on the top of the WhatsApp button, which will allow users to drag the button up and down. This won\'t work for the bottom-fixed button type.', 'add-whatsapp-button'); ?></p> 270 </td> 271 </tr> 272 <tr> 266 273 <th scope="row"><label for="awb_settings[breakpoint]"><?php echo esc_html__( 'Breakpoint', 'add-whatsapp-button' ); ?></label></th> 267 274 <td> -
add-whatsapp-button/trunk/includes/scripts-manager.php
r2997890 r2998159 49 49 $button_location = ( isset( $options['button_location'] ) ) ? $options['button_location'] : 'left'; 50 50 $buttonType = isset( $options['button_type'] ) ? $options['button_type'] : 'wab-side-rectangle'; 51 $dragEnabled = ! empty ( $options['enable_dragging'] ) ? $options['enable_dragging'] : 0; 51 52 52 53 // Create an array of the data we want to pass to the JS script … … 58 59 'button_location' => $button_location, 59 60 'button_type' => $buttonType, 61 'dragEnabled' => $dragEnabled, 60 62 'plugins_url' => plugins_url() 61 63 ); … … 72 74 */ 73 75 private function enqueue_jquery_ui_draggable() { 76 $options = Plugin::$instance->get_plugin_options(); 77 78 if ( ! empty ( $options['enable_dragging'] ) ? $options['enable_dragging'] : 0 ) { 79 return; 80 } 81 74 82 wp_enqueue_script( 'jquery_draggable', plugins_url( '../js/lib/jquery-ui.drag.min.js', __FILE__ ), array( 'jquery' ) ); 75 83 wp_enqueue_script( 'jquery_touch_punch', plugins_url( '../js/lib/jquery.ui.touch-punch.min.js', __FILE__ ), array( 'jquery' ) ); -
add-whatsapp-button/trunk/includes/style-templates/frontend-css.php
r2575242 r2998159 325 325 display: none; 326 326 } 327 328 /* Draggable */ 329 #wab_drag { 330 position: absolute; 331 z-index: 99998; 332 background-color: #20B038; 333 display: flex; 334 align-items: center; 335 justify-content: center; 336 cursor: grab; 337 } 338 339 .wab-side-rectangle #wab_drag { 340 top: 38px; 341 padding: 5px; 342 } 343 344 .wab-icon-plain #wab_drag { 345 top: 68px; 346 right: -7px; 347 padding: 9px 5px; 348 border: 3px solid white; 349 border-radius: 50%; 350 } 351 352 .wab-side-rectangle #wab_drag img { 353 height: 6px; 354 } 355 356 .wab-icon-plain #wab_drag img { 357 height: 4px; 358 } 327 359 </style> 328 360 -
add-whatsapp-button/trunk/js/wab.js
r2997914 r2998159 1 class WhatsAppButtonHandler{constructor(t){this.settings=wabSettings,this.$=t,this.getElements(),this.init()}getElements(){this.$buttonContainer=this.$("#wab_cont"),this.$whatsAppButton=this.$("#whatsAppButton"),this.$chevron=this.$("#wab_close img.wab-chevron"),this.$closeButton=this.$("#wab_close")}setButtonToggleWidth(){const t=this.$buttonContainer.outerWidth();let s="";"wab-side-rectangle"===this.settings.button_type?s=t-12+"px":"wab-icon-plain"===this.settings.button_type&&(s=t-14+"px"),this.$buttonContainer.css(this.settings.button_location,"-"+s)}toggleHideBottomRectangle(){this.$chevron.toggleClass("wab-down wab-up");const t=this.$whatsAppButton.outerHeight()-12+"px";this.$chevron.hasClass("wab-down")?(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-down.svg"),this.$buttonContainer.css("bottom",0)):this.$chevron.hasClass("wab-up")&&(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-up.svg"),this.$buttonContainer.css("bottom","-"+t))}toggleHideSideButton(){this.$chevron.toggleClass("wab-left wab-right"),this.$buttonContainer.hasClass("wab-hidden")?("left"===this.settings.button_location?this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-right.svg"):this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-left.svg"),this.setButtonToggleWidth()):(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-"+this.settings.button_location+".svg"),this.$buttonContainer.css(this.settings.button_location,0))}toggleHideCloseButton(){this.$buttonContainer.toggleClass("wab-hidden"),"wab-bottom-rectangle"===this.settings.button_type?this.toggleHideBottomRectangle():this.toggleHideSideButton()}onCloseButtonClick(){"full"===this.settings.hideButtonType&&this.$buttonContainer.hide(),"hide"===this.settings.hideButtonType&&this.toggleHideCloseButton()}handleButtonDisplayHours(){const t={startHour:this.settings.startHour,endHour:this.settings.endHour},s=(new Date).getHours();(s<parseInt(t.startHour)||s>parseInt(t.endHour))&&this.$buttonContainer.css("display","none")}init(){ this.$buttonContainer.draggable({axis:"y"}),this.$closeButton.on("click",(()=>this.onCloseButtonClick())),"1"===this.settings.limitHours&&this.handleButtonDisplayHours()}}jQuery(document).ready((t=>{new WhatsAppButtonHandler(t)}));1 class WhatsAppButtonHandler{constructor(t){this.settings=wabSettings,this.$=t,this.getElements(),this.init()}getElements(){this.$buttonContainer=this.$("#wab_cont"),this.$whatsAppButton=this.$("#whatsAppButton"),this.$chevron=this.$("#wab_close img.wab-chevron"),this.$closeButton=this.$("#wab_close")}setButtonToggleWidth(){const t=this.$buttonContainer.outerWidth();let s="";"wab-side-rectangle"===this.settings.button_type?s=t-12+"px":"wab-icon-plain"===this.settings.button_type&&(s=t-14+"px"),this.$buttonContainer.css(this.settings.button_location,"-"+s)}toggleHideBottomRectangle(){this.$chevron.toggleClass("wab-down wab-up");const t=this.$whatsAppButton.outerHeight()-12+"px";this.$chevron.hasClass("wab-down")?(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-down.svg"),this.$buttonContainer.css("bottom",0)):this.$chevron.hasClass("wab-up")&&(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-up.svg"),this.$buttonContainer.css("bottom","-"+t))}toggleHideSideButton(){this.$chevron.toggleClass("wab-left wab-right"),this.$buttonContainer.hasClass("wab-hidden")?("left"===this.settings.button_location?this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-right.svg"):this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-left.svg"),this.setButtonToggleWidth()):(this.$chevron.attr("src",this.settings.plugins_url+"/add-whatsapp-button/img/chevron-"+this.settings.button_location+".svg"),this.$buttonContainer.css(this.settings.button_location,0))}toggleHideCloseButton(){this.$buttonContainer.toggleClass("wab-hidden"),"wab-bottom-rectangle"===this.settings.button_type?this.toggleHideBottomRectangle():this.toggleHideSideButton()}onCloseButtonClick(){"full"===this.settings.hideButtonType&&this.$buttonContainer.hide(),"hide"===this.settings.hideButtonType&&this.toggleHideCloseButton()}handleButtonDisplayHours(){const t={startHour:this.settings.startHour,endHour:this.settings.endHour},s=(new Date).getHours();(s<parseInt(t.startHour)||s>parseInt(t.endHour))&&this.$buttonContainer.css("display","none")}init(){"1"===this.settings.dragEnabled&&this.$buttonContainer.draggable({axis:"y",scroll:!1,handle:"#wab_drag"}),this.$closeButton.on("click",(()=>this.onCloseButtonClick())),"1"===this.settings.limitHours&&this.handleButtonDisplayHours()}}jQuery(document).ready((t=>{new WhatsAppButtonHandler(t)})); -
add-whatsapp-button/trunk/plugin.php
r2575274 r2998159 186 186 <div id="wab_cont" class="wab-cont ui-draggable <?php echo $button_style; ?> <?php echo $button_location; ?>"> 187 187 <a id="whatsAppButton" href="https://wa.me/<?php echo esc_html( $settings['phone_number'] ); ?><?php echo ( !empty($settings['default_message']) && $settings['enable_message'] == '1' ) ? '/?text='. rawurlencode($settings['default_message']) : ''; ?>" target="_blank"><span class="<?php echo $displayNoneIfIcon; ?>"><?php echo $button_text; ?></span></a> 188 <?php if ( isset( $settings['enable_hide_button'] ) && ( isset( $settings['hide_button'] ) ) ) : ?> 188 <?php if ( isset( $settings['enable_dragging'] ) ) : ?> 189 <div id="wab_drag"><img src="<?php echo plugins_url( '/img/drag-horizontal.svg', __FILE__ ) ?>"></div> 190 <?php endif; ?> 191 <?php if ( isset( $settings['enable_hide_button'] ) && isset( $settings['hide_button'] ) ) : ?> 189 192 <div id="wab_close"><?php echo $close_button_icon; ?></div> 190 193 <?php endif; ?> -
add-whatsapp-button/trunk/readme.txt
r2997916 r2998159 4 4 Requires at least: 4.6 5 5 Tested up to: 6.4.1 6 Stable tag: 2.1. 16 Stable tag: 2.1.2 7 7 Requires PHP: 5.4 8 8 License: GPLv2 or later … … 53 53 54 54 == Changelog == 55 56 = 2.1.2 = 57 * Moved the button dragging functionality under a flag (admin setting) 58 * The dragging is now done by a small dragging handle instead of the entire button being draggable 55 59 56 60 = 2.1.1 =
Note: See TracChangeset
for help on using the changeset viewer.