Changeset 2328300
- Timestamp:
- 06/21/2020 06:49:41 PM (6 years ago)
- Location:
- mythic-smooth-scroll/trunk
- Files:
-
- 3 edited
-
js/smoothscroll.js (modified) (1 diff)
-
mythic-smooth-scroll.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mythic-smooth-scroll/trunk/js/smoothscroll.js
r1960397 r2328300 1 console.log('Smooth Scroll Initialized.'); 1 (function() { 2 3 "use strict"; 4 jQuery(document).ready(function($) { 5 $('a[href*=#]:not([href=#])').click(function() { 6 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') || location.hostname == this.hostname) { 7 var target = $(this.hash); 2 8 3 jQuery(document).ready(function($) { 4 $('a[href*=#]:not([href=#])').click(function() { 5 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') || location.hostname == this.hostname) { 6 var target = $(this.hash); 7 8 var headerHeight = 0; 9 10 if(smoothScrollData.headerID !=='') { 11 headerHeight += $('#' + smoothScrollData.headerId + '').outerHeight(); // Get fixed header height 9 var headerHeight = 0; 10 11 if(smoothScrollData.headerID !=='') { 12 headerHeight += $('#' + smoothScrollData.headerId + '').outerHeight(); // Get fixed header height 13 } 14 15 if(smoothScrollData.offsetAmount == '') { 16 smoothScrollData.offsetAmount = 50 17 } 18 19 var offset = parseInt(smoothScrollData.offsetAmount); 20 21 headerHeight += offset; // Add Offset 22 23 if(smoothScrollData.adminBar) { 24 headerHeight += $('#wpadminbar').outerHeight(); // Add Admin Bar Height 25 } 26 27 target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); 28 29 if (target.length) { 30 $('html,body').animate({ 31 scrollTop: target.offset().top - headerHeight 32 }, 500); 33 34 return false; 35 } 12 36 } 13 14 if(smoothScrollData.offsetAmount == '') { 15 smoothScrollData.offsetAmount = 50 16 } 17 18 var offset = parseInt(smoothScrollData.offsetAmount); 19 20 headerHeight += offset; // Add Offset 21 22 if(smoothScrollData.adminBar) { 23 headerHeight += $('#wpadminbar').outerHeight(); // Add Admin Bar Height 24 } 25 26 target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); 27 28 if (target.length) { 29 $('html,body').animate({ 30 scrollTop: target.offset().top - headerHeight 31 }, 500); 32 33 return false; 34 } 35 } 37 }); 36 38 }); 37 }); 39 40 })(jQuery); -
mythic-smooth-scroll/trunk/mythic-smooth-scroll.php
r1963259 r2328300 5 5 /* 6 6 Plugin Name: Mythic Smooth Scroll 7 Plugin URI: https://github.com/corybolles/Mythic-Smooth-Scroll8 7 Description: Simple jQuery smooth scroll plugin with optional offset for fixed headers. 9 Version: 1.0. 08 Version: 1.0.2 10 9 Author: Mythic Design Company 11 Author URI: http ://mythicdesigncompany.com10 Author URI: https://mythicdesigncompany.com 12 11 License: GPLv3 13 12 Text Domain: mythic-smooth-scroll … … 32 31 */ 33 32 34 defined('ABSPATH') or die( 'Please don\t access me in this way. I feel invaded.');33 defined('ABSPATH') or die(__("Please don't access me in this way. I feel invaded.", 'mythic_ss')); 35 34 36 35 function mythic_ss_register_settings() { … … 38 37 add_option( 'mythic_ss_offset_amount', '50'); 39 38 40 register_setting( 'mythic_ss_options', 'mythic_ss_header_id' );41 register_setting( 'mythic_ss_options', 'mythic_ss_offset_amount' );39 register_setting( 'mythic_ss_options', 'mythic_ss_header_id', array( 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field' )); 40 register_setting( 'mythic_ss_options', 'mythic_ss_offset_amount', array( 'type' => 'string', 'sanitize_callback' => 'sanitize_text_field' )); 42 41 } 43 42 add_action( 'admin_init', 'mythic_ss_register_settings' ); … … 54 53 55 54 <div> 56 <h1> Mythic Smooth Scroll</h1>55 <h1><?php _e('Mythic Smooth Scroll', 'mythic_ss'); ?></h1> 57 56 <form method="post" action="options.php"> 58 57 <?php … … 60 59 do_settings_sections( 'mythic_ss_options' ); 61 60 ?> 62 <label for="mythic_ss_header_id"><strong> Header ID (Leave blank if you're header is not fixed)</strong></label><br>63 <a href="#"> Not sure how to find this?</a><br>61 <label for="mythic_ss_header_id"><strong><?php _e("Header ID (Leave blank if your header is not fixed)", 'mythic_ss'); ?></strong></label><br> 62 <a href="#"><?php _e('Not sure how to find this?', 'mythic_ss'); ?></a><br> 64 63 <input type="text" id="mythic_ss_header_id" name="mythic_ss_header_id" value="<?php echo get_option('mythic_ss_header_id'); ?>" /><br> 65 64 <br> 66 <label for="mythic_ss_offset_amount"><strong> Scroll Offset Amount (Default is 50). Will be added to fixed header's height.</strong></label><br>65 <label for="mythic_ss_offset_amount"><strong><?php _e("Scroll Offset Amount (Default is 50). Will be added to fixed header's height.", 'mythic_ss'); ?></strong></label><br> 67 66 <input type="text" id="mythic_ss_offset_amount" name="mythic_ss_offset_amount" value="<?php echo get_option('mythic_ss_offset_amount'); ?>" pattern= "[0-9]+"/><br> 68 67 <br> -
mythic-smooth-scroll/trunk/readme.txt
r1963261 r2328300 3 3 Tags: smooth, scroll, jquery 4 4 Requires at least: 3.0.1 5 Tested up to: 4.9.85 Tested up to: 5.4.0 6 6 Requires PHP: 5.2.4 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 25 25 26 26 == Changelog == 27 1.0.2 28 Added internationlization. 29 Added strict mode to JS. 30 Added data sanitization. 31 27 32 1.0.1 28 33 Adjusted settings page UI, and added FAQs.
Note: See TracChangeset
for help on using the changeset viewer.