Oh, I’m sorry. The code snippet above does the opposite. It removes the buttons on mobile, and displays them on desktop. I should have read your post better.
Give this a try instead. It works in my tests:
// Check if we are on mobile
function jetpackme_is_mobile() {
// Are Jetpack Mobile functions available?
if ( ! function_exists( 'jetpack_is_mobile' ) ) {
return false;
}
// Is Mobile theme showing?
if ( isset( $_COOKIE['akm_mobile'] ) && $_COOKIE['akm_mobile'] == 'false' ) {
return false;
}
return jetpack_is_mobile();
}
// Let's remove the sharing buttons when on desktop
function jetpackme_maybe_add_filter() {
// On mobile, and on the home page?
if ( ! jetpackme_is_mobile() ) {
add_filter( 'sharing_show', '__return_false' );
}
}
add_action( 'wp_head', 'jetpackme_maybe_add_filter' );
If you still experience issues, I’d recommend flushing your site’s cache if you use a caching plugin.