There are many rules for writing the standard of Themeforest ready WordPress themes. Here we will discuss on WordPress standard to approve a theme in Themeforest.

  • Text Domain: The text domain the most important point for your theme. As per the guidelines theme name, theme folder name and the text domain should be the same. There should not be any blank space between the text domain you are using. Also, avoid camel case in text-domain. Also, it should be confirmed that only one text-domain is used in your theme. Text Domain should be specified in the style.css information header.
  • Prefix Everything: Prefix all your custom functions, variables, classes, hooks, public/global variables, and database entries to avoid conflict issues with plugins and other themes. A good rule of thumb is to prefix everything with your theme initials i.e your theme Text Domain. Please avoid camel cases in prefixes.

You’ll need to know how to use that prefix. While there aren’t always hard-n-fast rules, if you follow WordPress coding standards, things are very clear. The following is are the various items that you should prefix.

  • Function names
  • Class names
  • Global variables
  • Action hooks
  • Filter hooks
  • Script handles
  • Style handles
  • Image size names

There are many things in theme that should not be prefixed are follows :

  • Pluggable functions
  • Third-party script/style handles
  • Third-party PHP scripts/libraries
  • Mandatory Functions must be use :
  • wp_head()
  • wp_footer()
  • body_class() : for the body to add other classes need to use the hook add class in body_class()
  • post_class()
  • add_editor_style()
  • wp_nav_menu()
  • wp_site_icon()
  • Enqueue the Google fonts the right way and Don’t cache Google fonts :

Google should not cache using @import in any CSS file, the proper guidelines are given here https://themeshaper.com/2014/08/13/how-to-add-google-fonts-to-wordpress-themes/

  • To include Styles & Script :

wp_enqueue_style() must be used to enqueue all stylesheets and

wp_enqueue_script() must be used to add any JavaScript code to a page.

wp_add_inline_style() should be used where possible. Hook it with wp_enqueue_* and to be added from the functions file. This includes custom CSS. Hardcoded style is not allowed

Reference:https://developer.wordpress.org/reference/functions/wp_add_inline_style/

wp_add_inline_script() should be used where possible. Hook it with wp_enqueue_* and to be added from the functions file. This includes custom JavaScript. The hard-coded script is not allowed.

Reference:

NOTE: Keep all enqueued scripts are styles under a single function or at least reduce them, that way they will be easier to manage.

  • Screenshot Size : The screenshot.png should be 1200px X 900px in dimension.
  • Include files : Include files via get_template_directory() and not with get_template_part() or locate_template() because you’re not loading WordPress templates and core is very specific when it comes what is loading.

E.G : require_once( get_template_directory(). ‘/inc/functions/searchly-wc-functions.php’ );

  • Spell WordPress: Spell “WordPress” correctly in all public-facing text: all one word, with both an uppercase W and P.
  • Custom CSS using Customizer: The custom CSS option is not needed since the Additional CSS core feature is provided by WP 4.7

In this article we concentrate more on what we need to do, there are many we will talk about in the next few articles. We will also discuss which not be used.