Skip to content

Instantly share code, notes, and snippets.

@philipjewell
Created August 20, 2017 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philipjewell/7d3b0a60506026b78e1f3da6382533f0 to your computer and use it in GitHub Desktop.
Save philipjewell/7d3b0a60506026b78e1f3da6382533f0 to your computer and use it in GitHub Desktop.
PHP function check

function_check.php

If you're doing shared hosting, it is extremely likely your provider has some sort of restrictions on the platform for what you can run. You can use this script to test if the function you are trying to use is restricted by that provider:

To dowload it via CLI:

curl -O https://raw.githubusercontent.com/philipjewell/scraps-and-scripts/master/function_check.php

Just swap out the FUNCTION_HERE in the code with the function you are trying to test and run the script. Since this is a basic if/else statement, it will allow you to see if the function is able to fun on the server. If you're using WP CLI, you can run the following command within the actual WordPress in case the function you're checking against is custom to one of your themes or plugins:

wp eval-file function_check.php --debug
<?php
if (function_exists('FUNCTION_HERE')) {
echo "This function is available.";
} else {
echo "This function is not available.";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment