Skip to content

Instantly share code, notes, and snippets.

@tenman
Last active December 12, 2015 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenman/4759947 to your computer and use it in GitHub Desktop.
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
/*
* 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
}
}
@tenman
Copy link
Author

tenman commented Feb 12, 2013

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' ){ ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment