Support » Everything else WordPress » Theme developer doc re functions.php

  • On the page I need help with … It’s a page from Developer documentation for Themes … and it says on that page:

    “If a WordPress plugin calls the same function, or filter, as you do in your functions.php, the results can be unexpected, even causing your site to be disabled.”

    Can you explain why this gives unexpected results?

    I don’t understand why. eg … It seems that statement is saying that if I call add_action.php() in functions.php, as well as in my pugin, that the results are unexpected. But that doesn’t sound right to me.

    Thank you,

    Josh

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • tugbucket

    (@tugbucket)

    add_action() is a core function. So that wouldn’t cause an issue. What it’s saying if that say a plugin has a custom function called like do_this() and you write a function for your functions file and also call it do_this() that will cause an issue. You should notice that most plugins, or at least they should, would write like plugin_name_do_this() to make the function name unique to help possibly prevent the issue. So if you were wanting to write a custom function you could use like do_this_jsmith909() to make yours unique.

    Thread Starter jsmith909

    (@jsmith909)

    @tugbucket – Thanks for your reply. That’s what I thought it meant to say. I know of that issue, but that could be confusing for someone that doesn’t know. I’ll look for a way to submit to change that. What do you think of this wording…

    “If a function or filter in a WordPress plugin has the same name as one in functions.php, the results can be unexpected, even causing your site to be disabled. A good practice is for functions in a plugin, prefix them with the plugin name, eg ‘plugin_name_do_this()’.”

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.