Changeset 2618042
- Timestamp:
- 10/21/2021 10:41:48 PM (4 years ago)
- Location:
- sticky-header-oceanwp/trunk
- Files:
-
- 5 added
- 1 deleted
- 2 edited
-
LICENSE (added)
-
changelog.md (added)
-
languages/sticky-header-oceanwp-fr_FR.mo (added)
-
languages/sticky-header-oceanwp-fr_FR.po (added)
-
main.js (modified) (3 diffs)
-
readme.md (added)
-
readme.txt (deleted)
-
sticky-header-oceanwp.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sticky-header-oceanwp/trunk/main.js
r1946378 r2618042 2 2 3 3 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 9 5 function sticky_header_oceanwp(){ 10 6 11 7 var style = typeof(sticky_header_style) !== 'undefined' && sticky_header_style == 'shrink' ? 'shrink' : 'float'; 12 8 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 } 37 35 } 38 36 … … 51 49 'top': wpadmin_height, 52 50 'width': '100%', 53 'z-index': '99 999',51 'z-index': '998', 54 52 }); 55 53 site_header.next().css('margin-top', header_padding); … … 64 62 sticky_header_oceanwp(); 65 63 }); 64 65 $(window).scroll(function(){ 66 sticky_header_oceanwp(); 67 }); 68 69 sticky_header_oceanwp(); 70 66 71 67 72 }); -
sticky-header-oceanwp/trunk/sticky-header-oceanwp.php
r1946377 r2618042 3 3 * Plugin Name: Sticky Header OceanWP 4 4 * 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. 55 * Version: 1.0.7 6 6 * Author: Oren Hahiashvili 7 7 * Author URI: https://www.script.co.il 8 8 * Requires at least: 3.5.0 9 * Tested up to: 4.9.8 10 * 9 * Tested up to: 5.8 11 10 * Text Domain: sticky-header-oceanwp 12 11 * Domain Path: /languages/ 13 *14 12 */ 15 13 … … 19 17 } 20 18 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 30 19 class sticky_header_oceanwp { 31 20 32 21 function __construct() { 33 22 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' ) ); 35 24 } 36 25 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 } 37 39 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() { 39 54 load_plugin_textdomain( 'sticky-header-oceanwp', false, basename( dirname( __FILE__ ) ) . '/languages' ); 40 55 } 56 /* FRONT HANDLER END */ 41 57 42 58 59 /* ADMIN HANDLER START */ 43 60 function admin_menu() { 44 61 add_options_page( … … 54 71 } 55 72 56 function settings_page() {73 function settings_page() { 57 74 58 75 $sticky_header_styles = array( … … 85 102 <?php 86 103 } 104 /* ADMIN HANDLER END */ 105 106 87 107 } 88 108
Note: See TracChangeset
for help on using the changeset viewer.