Questions about prefixes and prefixing everything (functions, handlers etc)

wordpress

#1

I’ve got soft reject. It is not upsetting me at all. Just want to ask community about two things in hope other programmers will share their experience on this.

  1. I use ‘uni_themedomain_theme_’ prefix for all the functions and actions/filters in my theme. However I have got this msg from the reviewer:

"Prefix everything and use unique (theme-name-based) consistent slugs. Additional prefix is acceptable for when the author is using a framework.

Do not to use initials or abbreviations"

So, I feel like something wrong with my prefix. Is it really bad? Why (if your answer is ‘yes’)?
And this is my description of why I use this prefix:

  • ‘uni’ stands for framework like name, to mark functions written by me
  • ‘themedomain’ is a theme related part; also it is a domain name for a particular theme (e.g. ‘asana’)
  • ‘theme’ is added to distinguish things that are related to themes in general and/or contain translatable strings with a theme domain etc; I also make plugins, so it is quite useful to use this prefix

Does everybody use only ‘themedomain_’ prefix and that’s it? Pls, share your experience.

  1. About prefixing scripts/styles handlers. I was given this suggestion "To avoid double loading, don’t prefix third-party
    scripts and styles."
    And these are examles of what I use:
    ‘jquery-remodal’, ‘jquery-scrollreveal’, ‘js-cookie’. Actually, I haven’t prefixed it with special prefix. I used simple prefix just to highlght whether it is a pure js or based on jquery framework. That’s all. Also, I don’t khow how other authors
    prefix such things, so how I can be sure I do it right?)

Pls, share your experience on this too.

Thanks!


#2

I agree with you but the fact is “reviewer is always right”. Having your theme name as prefix can create conflicts later on, considering that envato allows same name to be used for new plugins and themes. And there are million other places to get plugins. But even though we don’t agree with the reviewer, the only option is we cannot use company name, our name etc as prefix with theme name. If someone knows why, please explain. @mrpsiho > You are not the only one in the boat.

Second part - You can remove jquery, js prefix or alternatively you can add those to the file name. I think the file name has to match with script id while enqueuing.


#3

I think the file name has to match with script id while enqueuing.

Good point. Thanks!


#4

Find all you need here http://themereview.co/prefix-all-the-things/ guys that run that site are WP theme reviewers. Good luck!


#5

I know of two additioanl options to prefixing issues (and seen them both in approved envato themes):
Singleton Factories–where you wrap all your functions inside a class.

PHP namespaces–described here: http://php.net/manual/en/language.namespaces.php

Of the two, the namespaces approach has always seemed like the most straightforward of the options as its at the top of the applicable files, and easily searchable for tracing an authors logic.


#6

Find all you need here http://themereview.co/prefix-all-the-things/3 guys that run that site are WP theme reviewers.

Actually no, this article doesn’t contain answers on my questions.


#7

Even if you use namespacing, the reviewer will still ask you for theme name prefix. Atleast my experience is so.


#8

PHP namespaces–described here: http://php.net/manual/en/language.namespaces.php

Namespaces are for classes. But I consider this as too much to create class for simple functions in functions.php


#9

Per the manual namespaces will pertain classes/functions/constants