I implement a class structure in my plugin, for example:

class Ethans_Plugin {
    public function __construct() {
        add_filter( 'admin_init', array( $this, 'admin' ), 10, 1 );
        add_action( 'admin_footer', array( $this, 'footer' ), 10, 1 );

    public function admin() {
        # code here...

    public function footer() {
        # code here...

When I define functions with generic names such as admin or footer will this conflict with any other function that have the same names? Or, since they are within a class, these function names will make them unique?


A method name is not callable without an instance of the class, so no, it cannot conflict with the same method names from other classes, because the class names, including the namespace, must be unique.

Btw: Never register callbacks in a constructor.

| improve this answer | |

yes. they could conflict. Always create your namespace. What if another ethan is thinking the exact same thing as you? MIND BLOWN!

| improve this answer | |
  • 1
    Could you provide an example of namespacing, maybe using his code? – Howdy_McGee Oct 25 '16 at 21:38
  • actually they can't conflict. to conflict a different plugin will need to use the same class name, so whatever conflit that ther might be will be on a different level – Mark Kaplun Oct 26 '16 at 1:38

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.