Plugin Directory

Changeset 2618042


Ignore:
Timestamp:
10/21/2021 10:41:48 PM (4 years ago)
Author:
scriptcoil
Message:

## [1.0.7] - 2021-10-22
### Support WordPress 5.8

  • Supporting until the latest version of WordPress 5.8
  • Fixed z-index issue, works with woocommerce quick previews as well.
  • Appreciate @mdmosharofsk for helping solve the bug
Location:
sticky-header-oceanwp/trunk
Files:
5 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • sticky-header-oceanwp/trunk/main.js

    r1946378 r2618042  
    22   
    33    var orginal_height = typeof(orginal_height==='undefined') || $('body').hasClass('fixed_sticky_active')==false ? $('#site-logo-inner').height() : orginal_height;
    4     $(window).scroll(function(){
    5         sticky_header_oceanwp();
    6     });
    7     sticky_header_oceanwp();
    8    
     4
    95    function sticky_header_oceanwp(){       
    106       
    117        var style = typeof(sticky_header_style) !== 'undefined' && sticky_header_style == 'shrink' ? 'shrink' : 'float';
    128
    13             var site_header = $('#site-header');
    14             var wpadmin_height = $('#wpadminbar').css('position') == 'fixed' && $('#wpadminbar').height() > 0 ? $('#wpadminbar').height() : 0;
    15             var top_bars = $('#wpadminbar').css('position') == 'fixed' ? $('#top-bar-wrap').height() : $('#top-bar-wrap').height() + $('#wpadminbar').height();
    16             var header_status = $(window).scrollTop() >= top_bars;
    17             var header_padding = site_header.height();
    18            
    19             if (style == 'float'){
    20 
    21            
    22             if (!header_status){
    23                 site_header.css({
    24                     'position': 'relative',
    25                     'top': '0',
    26                 });
    27                 site_header.next().css('margin-top', '0');
    28             }else{
    29                 site_header.css({
    30                     'position': 'fixed',
    31                     'top': wpadmin_height,
    32                     'width': '100%',
    33                     'z-index': '99999',
    34                 });
    35                 site_header.next().css('margin-top', header_padding);
    36             }   
     9        var site_header = $('#site-header');
     10        var wpadmin_height = $('#wpadminbar').css('position') == 'fixed' && $('#wpadminbar').height() > 0 ? $('#wpadminbar').height() : 0;
     11        var top_bars = $('#wpadminbar').css('position') == 'fixed' ? $('#top-bar-wrap').height() : $('#top-bar-wrap').height() + $('#wpadminbar').height();
     12        if (Number.isNaN(top_bars)){
     13            top_bars = $('#top-bar-wrap').height();
     14        }
     15        var header_status = $(window).scrollTop() >= top_bars;
     16        var header_padding = site_header.height();
     17       
     18        if (style == 'float'){
     19           
     20            if (!header_status){
     21                site_header.css({
     22                    'position': 'relative',
     23                    'top': '0',
     24                });
     25                site_header.next().css('margin-top', '0');
     26            }else{
     27                site_header.css({
     28                    'position': 'fixed',
     29                    'top': wpadmin_height,
     30                    'width': '100%',
     31                    'z-index': '998',
     32                });
     33                site_header.next().css('margin-top', header_padding);
     34            }   
    3735        }
    3836       
     
    5149                    'top': wpadmin_height,
    5250                    'width': '100%',
    53                     'z-index': '99999',
     51                    'z-index': '998',
    5452                });
    5553                site_header.next().css('margin-top', header_padding);
     
    6462        sticky_header_oceanwp();
    6563    });
     64       
     65    $(window).scroll(function(){
     66        sticky_header_oceanwp();
     67    });
     68   
     69    sticky_header_oceanwp();
     70
    6671   
    6772});
  • sticky-header-oceanwp/trunk/sticky-header-oceanwp.php

    r1946377 r2618042  
    33 * Plugin Name:         Sticky Header OceanWP
    44 * Description:         Want a new fresh sticky header like everyone else, with our plugin you can get the best and better sticky header that you ever seen
    5  * Version:             1.0.5
     5 * Version:             1.0.7
    66 * Author:              Oren Hahiashvili
    77 * Author URI:          https://www.script.co.il
    88 * Requires at least:   3.5.0
    9  * Tested up to:        4.9.8
    10  *
     9 * Tested up to:        5.8
    1110 * Text Domain: sticky-header-oceanwp
    1211 * Domain Path: /languages/
    13  *
    1412 */
    1513
     
    1917}
    2018
    21 add_action('wp_head', function(){
    22     echo '<script>var sticky_header_style = "'. get_option('oceanwp_header_style') .'";</script>';
    23 });
    24 add_action('wp_enqueue_scripts', function(){
    25         wp_enqueue_style( 'sticky-header-oceanwp-style', plugin_dir_url( __FILE__ ) . '/style.css', '1.0.0' );
    26         wp_enqueue_script( 'sticky-header-oceanwp', plugin_dir_url( __FILE__ ) . '/main.js', array( 'jquery' ), '1.0.0' );
    27 });
    28 
    29 
    3019class sticky_header_oceanwp {
    3120
    3221    function __construct() {
    3322        add_action( 'admin_menu', array( $this, 'admin_menu' ) );
    34         add_action( 'init', array( $this, 'myplugin_load_textdomain' ) );
     23        add_action( 'init', array( $this, 'init_stickyheader' ) );
    3524    }
    3625
     26    /* FRONT HANDLER START */
     27    function init_stickyheader(){
     28       
     29        // LOAD PLUGIN LANGUAGE TRANSLATION FILES
     30        $this->stickyheader_load_translations();
     31       
     32        // LOAD PLUGIN SCRIPTS AND STYLES
     33        add_action( 'wp_enqueue_scripts', array( $this, 'stickyheader_load_assets' ) );
     34       
     35        // OUTPUT BY SCRIPT VALUES STICKY HEADER STYLING TYPE
     36        add_action( 'wp_head', array( $this, 'stickyheader_output_style' ) );
     37
     38    }
    3739   
    38     function myplugin_load_textdomain() {
     40    function stickyheader_output_style(){
     41       
     42        echo '<script>var sticky_header_style = "'. get_option('oceanwp_header_style') .'";</script>';
     43       
     44    }
     45   
     46    function stickyheader_load_assets(){
     47       
     48        wp_enqueue_style( 'sticky-header-oceanwp-style', plugin_dir_url( __FILE__ ) . '/style.css', '1.0.0' );
     49        wp_enqueue_script( 'sticky-header-oceanwp', plugin_dir_url( __FILE__ ) . '/main.js', array( 'jquery' ), '1.0.0' );
     50       
     51    }
     52   
     53    function stickyheader_load_translations() {
    3954        load_plugin_textdomain( 'sticky-header-oceanwp', false, basename( dirname( __FILE__ ) ) . '/languages' );
    4055    }
     56    /* FRONT HANDLER END */
    4157   
    4258   
     59    /* ADMIN HANDLER START */
    4360    function admin_menu() {
    4461        add_options_page(
     
    5471    }
    5572
    56     function  settings_page() {
     73    function settings_page() {
    5774       
    5875        $sticky_header_styles = array(
     
    85102        <?php
    86103    }
     104    /* ADMIN HANDLER END */
     105   
     106   
    87107}
    88108
Note: See TracChangeset for help on using the changeset viewer.