This a continuing article to “Basic guidelines to approve a WordPress theme in Themeforest Part 1”. Here we discuss more points on how to approve a theme at ThemeForest.  We also do’s and don’ts here.

DO’s :

  • Sticky Post(s): should be designed or displayed differently from other posts. Use “sticky” class to style.
  • Post Navigation : Function next_post_link() and previous_post_link() should be use to do the post navigation in post details page i.e single.php
  • Widgets: All WordPress default widgets should be styled/displayed properly in all widgetized areas. You can check with the monster widgets plugin.  Custom widget areas must use the safety condition “is_active_sidebar” to ensure no naming conflict with other plugins.
  • Translation and Escape String: All strings within PHP variables must be translated and escaped.
    • use esc_html__( ‘Some String’, ‘text-domain ); instead of __( ‘Some String’, ‘text-domain );
    • use esc_html_e( ‘Some String’, ‘text-domain ); instead of _e( ‘Some string’, ‘text-domain );
    • sanitizing every URL using esc_url( ‘Some String’, ‘text-domain ); instead of a general link. Always use esc_url when sanitizing URLs (in text nodes, attribute nodes, or anywhere else). Rejects URLs that do not have one of the provided whitelisted protocols (defaulting to HTTP, HTTPS, FTP, ftps, mailto, news, IRC, gopher, NNTP, feed, and telnet), eliminates invalid characters and removes dangerous characters.
    • For some HTML: `wp_kses( __( ‘Some String something’, ‘text-domain’ ), $allowed_html_array );`
    • If dynamic data is rendered inside an attribute that triggers a JavaScript event, it must be escaped with esc_js().
  • Browser issues: Check the browser console and eliminate this errors if it is present.
    • Failed to load resource: the server responded with a status of 404 (Not Found)”
    • Failed to load resource: net::ERR_FILE_NOT_FOUND
    • Console Errors
  • Global variable: Globals should always be within a function or a class.
  • Files: Remove  empty and Unnecessary files
  • Plugin territory: Custom Post Types are plugin territory. Here are some other common examples: – Analytics – SEO options – Forms – Non-design related meta boxes – Resource caching – Dashboard widgets – Custom Post Types – Custom Taxonomies – Shortcodes – Social media “like”, “follow” and “share” buttons Anything that falls into plugin territory must be added via a custom plugin.
  • Localization or Translation: The localization file should be in English and delivered as.POT file.POT will contain all translation strings. .The POT file name should match the themes-slug. Theme can include actual translation files, but it should not add the en_US.mo or en_US.PO because English already implies
  • Documentation: Theme documentation layout must be structured, responsive.
  • Core CSS Classes: WordPress core classes should be implemented can be found https://codex.wordpress.org/CSS
  • Text Domain: The text domain should be the same as a theme in case of third-party code integration like Redux, CMB2, WooCommerce, etc.

Don’ts :

  • DO NOT unregister wordpress default widget using unregister_widget().
  • Don’t leave unused code fragments as comments in any files.
  • Don’t force_activation (in TGMPA).
  • DO NOT echo a variable using “echo $”.
  • Do not hardcode the image tag alt attribute.
  • Do not need to enqueue predefined scripts or styles of WordPress. [ https://developer.wordpress.org/reference/functions/wp_enqueue_script/ ], Just write array(‘script handles’) in your dependency script.
  • DO NOT use get_stylesheet_directory() when including the plugin source. Instead use get_template_directory() .
  • Do not use __FILE__
  • Do not use __DIR__
  • Do not use opendir() in themes because it is not particularly safe. Some hosts will disable it by default.
  • DO NOT use  E_USER_ERROR constants explicitly since core handles this.
  • Do not show Post Title twice on the same page.