Skip to content

Instantly share code, notes, and snippets.

@nunof07
Last active April 12, 2019 14:22
Show Gist options
  • Save nunof07/b44d07286fd8c4c00aacb250fd7015c1 to your computer and use it in GitHub Desktop.
Save nunof07/b44d07286fd8c4c00aacb250fd7015c1 to your computer and use it in GitHub Desktop.
Only show ACF admin page on local domain
<?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