Plugin Directory

Changeset 2328300


Ignore:
Timestamp:
06/21/2020 06:49:41 PM (6 years ago)
Author:
corybolles
Message:

Update to v 1.0.2

Location:
mythic-smooth-scroll/trunk
Files:
3 edited

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);
    28
    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                }
    1236            }
    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        });
    3638    });
    37 });
     39   
     40})(jQuery);
  • mythic-smooth-scroll/trunk/mythic-smooth-scroll.php

    r1963259 r2328300  
    55/*
    66Plugin Name: Mythic Smooth Scroll
    7 Plugin URI: https://github.com/corybolles/Mythic-Smooth-Scroll
    87Description: Simple jQuery smooth scroll plugin with optional offset for fixed headers.
    9 Version: 1.0.0
     8Version: 1.0.2
    109Author: Mythic Design Company
    11 Author URI: http://mythicdesigncompany.com
     10Author URI: https://mythicdesigncompany.com
    1211License: GPLv3
    1312Text Domain: mythic-smooth-scroll
     
    3231*/
    3332
    34 defined('ABSPATH') or die('Please don\t access me in this way. I feel invaded.');
     33defined('ABSPATH') or die(__("Please don't access me in this way. I feel invaded.", 'mythic_ss'));
    3534
    3635function mythic_ss_register_settings() {
     
    3837   add_option( 'mythic_ss_offset_amount', '50');
    3938   
    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' ));
    4241}
    4342add_action( 'admin_init', 'mythic_ss_register_settings' );
     
    5453
    5554    <div>
    56         <h1>Mythic Smooth Scroll</h1>
     55        <h1><?php _e('Mythic Smooth Scroll', 'mythic_ss'); ?></h1>
    5756        <form method="post" action="options.php">
    5857            <?php
     
    6059                do_settings_sections( 'mythic_ss_options' );
    6160            ?>
    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>
    6463            <input type="text" id="mythic_ss_header_id" name="mythic_ss_header_id" value="<?php echo get_option('mythic_ss_header_id'); ?>" /><br>
    6564            <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>
    6766            <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>
    6867            <br>
  • mythic-smooth-scroll/trunk/readme.txt

    r1963261 r2328300  
    33Tags: smooth, scroll, jquery
    44Requires at least: 3.0.1
    5 Tested up to: 4.9.8
     5Tested up to: 5.4.0
    66Requires PHP: 5.2.4
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    2525
    2626== Changelog ==
     271.0.2
     28Added internationlization.
     29Added strict mode to JS.
     30Added data sanitization.
     31
    27321.0.1
    2833Adjusted settings page UI, and added FAQs.
Note: See TracChangeset for help on using the changeset viewer.