0

I am developing a Wordpress plugin, wordpress states that "All plugins must have unique function names, namespaces, defines, and class names. "

A good way to do this is with a prefix. For example, if your plugin is called "Easy Custom Post Types" then you could use names like these:

function ecpt_save_post()
define( ‘ECPT_LICENSE’, true );
class ECPT_Admin{}
namespace EasyCustomPostTypes;

My question is that if my class is under a unique namespace, do I still need a unique class, function name. Example my name plugin name is XYZ. So I create a namespace for admin folder and have XYZ as the prefix: XYZAdmin

<?php
namespace XYZAdmin

class Hello { public function hello() {)}

In this case, do I still need a unique class and function name like class XYZHello, function xyzHello(). Is this enough if I prefix my namespace like that?

coinhndp
  • 2,281
  • 9
  • 33
  • 64
  • Ttake a look at the accepted answer on the question above, it should clear it up for you. But basically, no your functions do not need unique names because the combination of **unique namespace (or classname) + functionname** will make it unique. – FluffyKitten Aug 21 '20 at 12:19
  • 1
    Thanks for your help! It is what I want –  coinhndp Aug 21 '20 at 13:33

0 Answers0