Skip to content

Instantly share code, notes, and snippets.

@nunof07

nunof07/functions.php

Last active Apr 12, 2019
Embed
What would you like to do?
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