public
Created

WordPress Raindrops theme function raindrops_small_device_helper() has bug. Fixed code below.

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
/* WordPress theme Raindrops 1.004 line:3035
* function raindrops_small_device_helper has bug
* header image display improperly when uploading files 'Organize my uploads into month- and year-based folders' checked
* Please change below
* This bug will be fixed next versions Raindrops
*/
 
if ( ! function_exists( 'raindrops_small_device_helper' ) ) {
function raindrops_small_device_helper(){
global $is_IE, $raindrops_fluid_maximum_width;
$raindrops_header_image_uri = get_header_image();
?>
<script type="text/javascript">
(function(){
jQuery(function(){
var width = jQuery('div#header-image').width();
function raindrops_resizes(){
var image_exists = '<?php echo $raindrops_header_image_uri;?>';
var width = jQuery('div#header-image').width();
var window_width = jQuery(window).width();
 
if( image_exists !== '' ){
<?php
$url = get_theme_mod( 'header_image' );
 
if( $url == 'random-uploaded-image'){
$url = get_random_header_image();
}
 
$uploads = wp_upload_dir();
$file_name = basename( $url );
$child_path = '/'. $file_name;
$path = $uploads['path']. $child_path;
 
if( $url !== 'remove-header' ){
if( file_exists( $path ) ){
list($img_width, $img_height, $img_type, $img_attr) = getimagesize($path);
$ratio = $img_height / $img_width;
}else{
$raindrops_hd_images_path = get_template_directory().'/images/headers/'. basename( $url );
$ratio = 0.2084210;
}
?>
var ratio = <?php echo $ratio;?>;
var height = width * ratio;
 
jQuery('#header-image').removeAttr('style').css({'background-image':'url('+ image_exists + ')','height': height, 'background-size': 'cover'});
<?php }//remove header ?>
}
<?php
/**
* Check window size and mouse position
* Controll childlen menu show right or left side.
*
*
*
*/
?>
if ( jQuery('body > div').is('#doc3') ) {
jQuery("#access").mousemove(function(e){
var menu_item_position = e.pageX ;
 
if( window_width - 200 < menu_item_position){
jQuery('#access ul ul ul').addClass('left');
}else if( window_width / 2 > menu_item_position){
jQuery('#access ul ul ul').removeClass('left');
}
});
if( window_width > <?php echo $raindrops_fluid_maximum_width;?>){
//centering page when browser width > $raindrops_fluid_maximun_width
jQuery('#doc3').css({'margin':'auto'});
}
}
}
raindrops_resizes();
jQuery(window).resize( function () {raindrops_resizes()});
});
})(jQuery);
</script>
<?php
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.