I am trying to secure the copyrights links from footer.php file and I want to create a function in footer php which will have those links and then I want to check from functions.php if that function exists in the footer and in case it doesn't I would like to show an exit(); function. I am also planning to encode the footer and functions php code.

I tried function_exists() but it works only if the function I am checking is in the same file as function_exists is. Can anybody give me any idea on how to solve this? Tank you!


You should not declare functions in your templates. The templates are for outputting content. The function_exists() will check if the function is declared before the function_exists() call, not after it, and templates are loaded after functions.php file, since you can control them by using the template_redirect filter.

Declare your function in your theme's functions.php file, and then call it in your template. This is the best way to go.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.