Email Users
[resolved] use specific function names (4 posts)

  1. acub
    Posted 4 years ago #


    I'm using your plugin and I really appreciate your work and effort. However, I'd like to make a suggestion: you are using very general function names, such as "get_column", "get_sortable_columns", "prepare_items" and so on. Being so general, there are big chances that some other plugin developers give the same name to their functions aswell, and that's going to cause problems to either your plugin or theirs, depending on which one loads first.

    I'm suggesting you prefix all your function names with the initials of your plugin and change the above examples in "eu_get_column", "eu_get_sortable_columns", "eu_prepare_items" and so on...

    I hope this helps. Keep up the good work.

    Regards, Andrei.


  2. Mike Walsh
    Plugin Author

    Posted 4 years ago #

    Those functions are wrapped in the child class WP_List_Table instance and must have those names for the class to function properly. If you see some functions outside of a class that don't have the "mailusers_" prefix let me and I'll take a look. Everything within the plugin should be using that prefix to avoid collisions.


  3. acub
    Posted 4 years ago #

    Thank you for explaining that to me. There's only one more thing I'd like to know. If more than one plugin uses the same class, are there going to be problems? Or each will have their own instance?

  4. Mike Walsh
    Plugin Author

    Posted 4 years ago #

    It depends. If two different plugins were to define a class by the exact same name, there would a problem and PHP will generate an error. It is perfectly acceptable for multiple plugins to create unique instances of a class for their own use and doing so is good programming.

    If a plugin wants to leverage an existing class and build on it, the proper thing to do is to create a child class which is what Email Users does with the WP_List_Table class.

    class MailUsers_List_Table extends WP_List_Table {
    // Code that extends the child class or overloads the
    // existing methods will appear here in the body of the class.

    Hope that helps clear things up.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Email Users
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.