Last active
March 30, 2017 06:35
-
-
Save raftaar1191/8434ab7ee82fbacbfc2a54cccf748ef5 to your computer and use it in GitHub Desktop.
BuddyPress issue
This file contains hidden or 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
<?php | |
/** | |
* Add script for mobile device in BuddyPress profile page only. | |
* | |
* Change style of uploader that used to change profile picture and cover photo. | |
*/ | |
function tmp_rtmedia_wp_footer_callback() { | |
// Check if it is a mobile device and bp_is_my_profile function exist also it an BuddyPress profile page. | |
if ( wp_is_mobile() && function_exists( 'bp_is_my_profile' ) && bp_is_my_profile() ) { | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
// Run after 1.5 second. | |
setTimeout( function(){ | |
// BuddyPress Uploader container. | |
var $upload_ui = '#bp-upload-ui'; | |
var $new_html = $upload_ui +' .moxie-shim-html5'; | |
// Check if BuddyPress Uploader container exist. | |
if ( jQuery( $upload_ui ).length || jQuery( $upload_ui ).size() ) { | |
// Check if BuddyPress Uploader container object added. | |
if ( jQuery( $new_html ).length || jQuery( $new_html ).size() ) { | |
// Get all the style tag. | |
var new_html_style = jQuery( $new_html ).attr( 'style' ); | |
// Chaining string to array separated by semicolon. | |
var new_html_style = new_html_style.split( ';' ); | |
// new_html_style for loop. | |
jQuery.each( new_html_style, function( index, item ) { | |
// Check if in the string is top or left. | |
if ( item.indexOf("top:") >= 0 || item.indexOf("left:") >= 0 ) { | |
// Add important to the string. | |
new_html_style[ index ] = item + ' ! important'; | |
} | |
}); | |
// Joining array to string separated by semicolon. | |
new_html_style = new_html_style.join(';'); | |
// Adding to style attribute. | |
jQuery( $new_html ).attr( 'style', new_html_style ); | |
} | |
} | |
}, 1500 ); | |
}); | |
</script> | |
<?php | |
} // End if(). | |
} | |
add_action( 'wp_footer', 'tmp_rtmedia_wp_footer_callback', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment