Last active
April 12, 2019 14:22
-
-
Save nunof07/b44d07286fd8c4c00aacb250fd7015c1 to your computer and use it in GitHub Desktop.
Only show ACF admin page on local domain
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
<?php | |
/** | |
* Determines if string ends with a specific sub string. | |
* | |
* @param string $haystack The string to search in. | |
* @param string $needle The sub-string to search for. | |
* @return boolean | |
*/ | |
function string_ends_with($haystack, $needle) { | |
$length = strlen($needle); | |
return $length === 0 || (substr($haystack, -$length) === $needle); | |
} | |
/** | |
* Only show Custom Fields admin page on ".local" address. | |
*/ | |
add_filter('acf/settings/show_admin', function () { | |
return string_ends_with( | |
get_bloginfo('url'), | |
'.local' | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment