Simple Tips to Getting Approved on ThemeForest

1.debug true:

2.html, css, php, javascript coding standard maintain:

3.Prefix Everything:

For my WordPress themes, I use the themename_ prefix all around, as it is simple and clean.

// Functions
function prefix_setup()

// Classes
class Prefix_Class {}

// Global Variables
global $prefix_passengers;

// Action Hooks
do_action( ‘prefix_start_engine’ );

// Filter Hooks
$register = apply_filters( prefix_register );

// Non Third-Pary Script Handles
wp_enqueue_script( 'prefix-functions', get_theme_directory_uri() . 'js/custom/functions.js' );

// Non Third-Pary Style Handles
wp_enqueue_style( 'prefix-minified-style', get_theme_directory_uri() . 'style.min.css' );

// Images
add_image_size( 'prefix-large', 800, 600 );

4.Properly Include Scripts and Styles:

Do Not Prefix Third Party Scripts.

 * Third Party Styles
 * More info:
// Incorrect 
	wp_enqueue_style( 'prefix-font-awesome', get_template_directory_uri() . '/css/font-awesome.css', array(), '4.2.0', 'all' );

// Corrrect 
	wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.css', array(), '4.2.0', 'all' );

 * Third Party Scripts
// Incorrect 
	wp_enqueue_script( 'prefix-fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '1.1.1', true );

// Corrrect 
	wp_enqueue_script( 'jquery-fitvids', get_template_directory_uri() . '/js/jquery.fitvids.js', array( 'jquery' ), '1.1.1', true );

5.Escape Everything:


// Use anytime HTML element encloses a section of data:

	echo esc_html( $no_html );

// Use on all URLs, including those in the 'src' and 'href' attributes of an HTML element:

	<img src="<?php echo esc_url( $escaped_url ); ?>" />

// Use for inline Javascript:

	<a href="#" onclick="<?php echo esc_js( $escaped_js ); ?>">
		<?php esc_html__( 'Click Here', 'text-domain' ); ?>

// Use for an HTML attribute:

	<div class="<?php echo esc_attr( $escaped_class ); ?>">

6.Check for PHP Errors and Warnings:

One of the easiest errors to check for is standard PHP errors. Enable wp_debug and go to town self-reviewing your theme to ensure there are no PHP errors, notices or warnings anywhere

7.Update TGMPA:

Keep in mind that every time you release a new version of your theme, you should double check that the latest version of TGMPA is included.

8.Properly Include Plugins Using TGMPA:

// Include a plugin from the WordPress Repository:
  'name'      => esc_html__( 'WooCommerce', 'text-domain' ),
  'slug'      => 'woocommerce',
  'required'  => false,

// Include a plugin bundled within a WordPress theme:
  'name'      => esc_html__( 'Example Plugin', 'text-domain' ),
  'slug'      => 'example-plugin',
  'source'    => get_template_directory() . '/inc/plugins/',
  'required'  => false,

9.Disable TGMPA Force Actions:

Every user should have free rein to activate or deactivate any WordPress plugins installed on their website.

10.Theme Unit Test:

Common issues are table display errors, image alignments, responsive comments, pingbacks display errors, password-protected post styling issues, and search index mishaps.

11.Run Theme Check:

Theme Check is literally the easiest way to check your WordPress theme against the latest coding standards and techniques

12.html markup validation:

13.Provide Offline and online Documentation:

Having offline documentation ensures that your customers are not hanging when there is not an Internet connection available or when your files are inaccessible – for any reason.


WordPress Information

ওয়ার্ডপ্রেস টার্মিনোলজি

1.slug (mean user friendly url)
2.Template Hierarchy ( ওয়ার্ডপ্রেসে পাট্টিকুলারলি যদি কিছু ফাইল থাকে ওয়ার্ডপ্রেস আগে সেই ফাইলটা দিয়ে কন্টেন্ট দেখায়। যদি ওটা না থাকে তাহলে আরেকটা ফাইল দিয়ে চেক করে যে এ ফাইলটা আছে কিনা তখন সেটা দিয়ে কন্টেন্ট দেখায়। যদি সেটাও না থাকে তাহলে আরেকটা ফাইল দিয়ে কন্টেন্ট দেখায় এভাবে সবশেষে কেউ যদি না থাকে তাহলে index.php দিয়ে কন্টেন্ট দেখায়। এই যে ওর্ডারটা, কন্টেন্ট দেখানোর জন্য কোন টেমপেল্ট ফাইলটা লোড হবে কোন php ফাইলটা লোড হবে। এই ওর্ডারটাকেই বলা হয় Template Hierarchy )

3.Taxonomy And Terms (Categories, Tags)
4.Transient (Temporary Storage)

What is hook?

হুক আসলে জাস্ট একটা ইভেন্ট ব্রডকাস্টিং সিস্টেম। দুই রকমের হুক আছে, অ্যাকশন হুক এবং ফিল্টার হুক

প্লাগেবল ফাংশন কি?

একটা ফাংশনকে এমন ভাবে ডিফাইন করা হয়, যাতে করে ইউজার সেই ফাংশনটি রিরাইট করতে পারে। অথাৎ একটা কন্ডিশনের ভিক্তিতে চেক করা হয় ফাংশনটি লিখা হয়েছে কিনা? যদি না হয় তাহলে ফলবেক হিসেবে কারেন্ট ফাংশনটিকে রির্টান করে। আর যদি থাকে তার মানে সেই existing ফাংশনটিকে নতুন করে লিখা হয়েছে। তখন সে নতুনটাকে রির্টান করে।

Cron job has not been configured yet

Installation extension error

PS D:\xampp\htdocs\magento2> php bin/magento setup:cron:run
#!/usr/bin/env php
setup-cron: Please check var/log/update.log for execution summary.

You can see
setup-cron.ERROR: Your current PHP memory limit is 328M. Magento 2 requires it to be set to 756M or more. As a user with root privileges, edit your php.ini file to increase memory_limit.

See if the following file exists:
Magento install dir/var/.setup_cronjob_status
If the file exists, cron has run successfully in the past.


commented out :
//$setupCheck = $this->cronScriptReadinessCheck->checkSetup();
//$updaterCheck = $this->cronScriptReadinessCheck->checkUpdater();

and replaced it with :
$setupCheck = ['success' => 1];
$updaterCheck = ['success' => 1];

Magento2 Snippets

|| Call phtml file in static block or cms page

   custom file path(Based on your theme you can change it)

   calling in xml layout file
   <block class="Magento\Framework\View\Element\Template" name="test_file" template="Magento_Theme::html/test.phtml"/>

   calling in blocks and cms pages
   {{block class="Magento\Framework\View\Element\Template" name="test_file" template="Magento_Theme::html/test.phtml"}}

   calling in any phtml file
   <?php include ($block->getTemplateFile('Magento_Theme::html/test.phtml')) ?>

   as before 
   <?php echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Magento_Theme::html/test.phtml")->toHtml();?>

Create an Admin theme

1.Create Admin theme directory
In the app/design/adminhtml directory create a new <Vendor>/<admin_theme> directory.

2.Add a declaration theme.xml
Add or copy from an existing theme.xml to your theme directory app/design/adminhtml/Vendor/<admin_theme>

<theme xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
	<title>Ataur Admin</title> <!-- your theme's name -->
	<parent>Magento/backend</parent> <!-- the parent theme. Example: Magento/backend -->

3.Add registration.php
In your theme directory app/design/adminhtml/<Vendor>/<admin_theme> create a registration.php file.

 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
	'adminhtml/Ataur/my-first-admin-theme', // Example: 'adminhtml/Magento/backend'

4.Admin theme logo
In the default Magento/backend theme lib/web/images/magento-logo.svg is used as theme logo. To override it, in your theme directory, create a web/images sub-directory, and add your custom file named magento-logo.svg

5.Apply an Admin theme
1.Set your Magento application to the developer mode.
2.Create a custom theme for the Admin panel.
3.Add a new custom module or decide to use existing custom module. The module must load after the Magento_Theme module. To ensure this, add the following code app/code/[VendorName]/[ModuleName]/etc/module.xml

(replace placeholders with your module information):

<module name="Ataur_Override" setup_version="2.0.1"> <!-- Example: "Magento_Backend -->"
		<module name="Magento_Theme"/>

6.Specify the custom Admin theme in di.xml
You need to specify the admin theme to be used in the <your_module_dir>/etc/di.xml file. Add it, if the file does not yet exist in your module.

<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
	<!-- Admin theme. Start -->
	<type name="Magento\Theme\Model\View\Design">
			 <argument name="themes" xsi:type="array">
				 <item name="adminhtml" xsi:type="string">Ataur/my-first-admin-theme</item> <!-- Example: "Magento/backend" -->
	<!-- Admin theme. End -->

7.Update components to actually apply the Admin theme
For your changes to take effect, you need to update Magento components. For this,
run the php bin/magento setup:upgrade command in your command line. If prompted, also run
php bin/magento setup:di:compile

error face: Controller preference not working after setup:di:compile
solution: Have you tried to run php bin/magento setup:static-content:deploy afterwards?
And just in case, run again php bin/magento setup:upgrade at the very end of operations.

Magento2 Installation

Magento2 download by composer

1.You have to setup composer in your htdocs
2.Must be check magento prerequisites
3.Go to magento documentation and find on the left side Getting Started > Install Magento using Composer
3.Select which version is compatibility with your php
4.Avoiding so many problem just change from D:\xampp\php\php.ini



5.Enter the following command. Obviously copy this code from Magento Open Source metapackage. Fact of (version)

php composer.phar create-project –repository-url= magento/project-community-edition directoryName


composer create-project –repository-url= magento/project-community-edition directoryName

Version specify:
php composer.phar create-project –repository-url= magento/project-community-edition=2.1.7 /installation/directoryName

6.When prompted, enter your authentication keys from your magento profile.
Your public key is your username.
your private key is your password.

7.Now you can see it’s downloading so many files. After few minutes Successfully you can see
Generating autoload files

Magento2 install by command line

D:\xampp\htdocs\magento2> composer
D:\xampp\htdocs\magento2> composer install
D:\xampp\htdocs\magento2> php bin/magento setup:install

php bin/magento setup:install –base-url= –db-host=localhost –db-name=test-magento2 –db-user=root –db-password= –admin-firstname=Ataur –admin-lastname=Rahman – –admin-user=webTech –admin-password=webTech1234@ –language=en_US –currency=USD –timezone=America/Chicago –use-rewrites=1

Magento 2 CLI

php bin/magento help
php bin/magento list
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento cache:disable
php bin/magento cache:enable
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

[doest not generate files in the pub/static folder. Try to run below command]
php bin/magento setup:static-content:deploy -f

Set the Magento mode

Developer mode:
You should use the Developer mode while you are developing customizations or extensions

php bin/magento deploy:mode:show
php bin/magento deploy:mode:set developer

Production mode:
You should run Magento in Production mode once it is deployed to a production server. Production mode provides the highest performance in Magento 2.

Install sample data after Magento

Do not install sample data if your Magento application is set for production mode. Switch to developer mode first. Installing sample data in production mode fails.

php bin/magento sampledata:deploy

If you’re installing sample data after installing Magento, you must also run the following command to update the database and schema:

php bin/magento setup:upgrade

WordPress Snippets

/* Tag list */
the_tags(' ', ' ', ' ');
echo get_the_tag_list("<ul class=\"list-unstyled text-center\"><li>", "</li><li>", "</li></ul>");

/* Get All tags */
$tags = get_tags();
$html = '<div class="post_tags">';
foreach ( $tags as $tag ) {
	$tag_link = get_tag_link( $tag->term_id );
	$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
	$html .= "{$tag->name}</a>";
$html .= '</div>';
echo $html;

/* Post thumbnail */
	the_post_thumbnail('large', array('class' => 'img-fluid'));   

/* Comments */
if(comments_open()): ?>
	<div class="col-md-10 offset-md-1">
		<?php comments_template();?>
<?php endif;

/* Post pagination */
	"screen_reader_text" => ' '

/* template file included */

/* php file or lib included */

/* post navigation */
echo "<br>";

/* password protected post */
function alpha_protected_post($excerpt){
	if (! post_password_required()) {
		return $excerpt;
		echo get_the_password_form();

add_filter('the_excerpt', 'alpha_protected_post');

/* css added in header */
function launcher_style(){
	if (is_page()) {
		$thumb_img = get_the_post_thumbnail_url( null, 'large' );
				background-image: url(<?php echo $thumb_img;?>);

add_action( 'wp_head', 'launcher_style', 11);

/* custom meta field data retrieve */
$placeholder = get_post_meta( get_the_ID(), 'placeholder', true );

/* post format */
$alpha_format = get_post_format();

/* author info */

/* author image */
echo get_avatar( get_the_author_meta( 'id') );

/* body class remove or add */
function alpha_body_class($classes){
	unset($classes[array_search('wp-custom-logo', $classes)]);
	$classes[] = "newclass_add";
	return $classes;

add_filter( 'body_class','alpha_body_class');

/* post class remove or add */
function alpha_post_class($classes){
	unset($classes[array_search('tag-blog', $classes)]);	
	return $classes;

add_filter( 'post_class','alpha_post_class');

/* image srcset remove */
function alpha_image_srcset(){
	return null;
add_filter( 'wp_calculate_image_srcset', 'alpha_image_srcset' );

/* If you want to override a function into the child theme, just put in a check */
if(!function_exists('alpha_date')) {
	function alpha_date(){
		echo date("d/m/y");