Last active
June 23, 2022 15:35
-
-
Save Patabugen/7f88cdcc42b9e0fbd9ab8062404f33d5 to your computer and use it in GitHub Desktop.
Workaround for Simple Share Buttons and front end caching
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 | |
/** | |
* The Simple Share Buttons uses wp_is_mobile() to decide how to render front end | |
* pages, which is incompatible with frontend caching. So filter the check | |
* to always return the "mobile version" (unless we are in the admin backend). | |
* | |
* Bbeware! It overrides _all_ frontend calls, not just SSBA ones). | |
* | |
* Save this as a mu-plugin ( wp-content/mu-plugins/disable-wp-is-mobile.php ) | |
* or paste it into your functions.php file | |
* | |
* @see https://wordpress.org/support/topic/disable-wp_is_mobile-checks/ | |
* @see https://developer.wordpress.org/reference/functions/wp_is_mobile/ | |
* | |
*/ | |
add_filter( 'wp_is_mobile', function($is_mobile){ | |
if (!is_admin()) { | |
return true; | |
} | |
return $is_mobile; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment