Last active
December 12, 2015 10:29
-
-
Save tenman/4759947 to your computer and use it in GitHub Desktop.
WordPress Theme Raindrops 1.008 has bug Please replace raindrops_small_device_helper function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Raindrops 1.008 can not remove custom header image. | |
* | |
* WordPress Theme Raindrops 1.008 has bug Please replace raindrops_small_device_helper function | |
* functions.php | |
*/ | |
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(); | |
$raindrops_header_image = get_custom_header(); | |
$raindrops_header_image_uri = $raindrops_header_image -> url; | |
if( empty( $raindrops_header_image_uri ) ){ | |
/* when restore image $raindrops_header_image -> url is empty */ | |
$raindrops_header_image_uri = get_header_image(); | |
} | |
$raindrops_header_image_width = $raindrops_header_image -> width; | |
$raindrops_header_image_height = $raindrops_header_image -> height; | |
?> | |
<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(); | |
<?php | |
$raindrops_restore_check = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) ); | |
if( $raindrops_restore_check !== 'remove-header' ){ | |
$ratio = $raindrops_header_image_height / $raindrops_header_image_width; | |
?> | |
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 | |
} | |
/** | |
* 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
restore image submit then can not show default image.
reason $raindrops_header_image -> url return empty string.
if( get_header_image() !== false) check works improperly.
then change code.
$raindrops_restore_check = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
if( $raindrops_restore_check !== 'remove-header' ){ ....