Date Functions and Formats

Date in PHP <time data-publish-date="<?php echo esc_attr( sprintf( '%s 00:01', current_time( 'Y-m-d', false ) ) ); ?>" data-relative-time-timezone="<?php echo esc_attr( get_option( 'timezone_string' ) ); ?>"> <span class="day"> <?php echo esc_html( sprintf( '%s, ', current_time( 'l', false ) ) ); ?> </span> <?php echo esc_html( current_time( 'F d, Y', false ) ); ?> </time> Date in … Continue reading Date Functions and Formats

Using Templates in WordPress

In themes: get_template_part( 'slug-name', 'name' );We should keep our templates inside template-parts directory.So lets say our template file is in: themes/theme-name/template-parts/home/home-my-template.phpTo include this template you will write ( for e.g. inside front-page.php ) get_template_part( 'template-parts/home/home', 'my-template' ); For e.g. our template file is in: themes/theme-name/template-parts/home/my-template.php get_template_part( 'template-parts/home', 'my-template' ); In Plugin, For e.g. our template … Continue reading Using Templates in WordPress

Using Underscore JS _.template() in WordPress

Many times we come across a situation in JavaScript where we have to generate dynamic html let content = '<li class="list-item">' + '<div class="details">' + '<h3>{ title }</h3>' + '<p>{ description }</p>' ++ '</div>' + '</li>'; You can see the code above looks messy and difficult to read. WordPress recommends to use underscore templates.WordPress already has … Continue reading Using Underscore JS _.template() in WordPress

Using underscore template in WordPress

Many times we come across a situation in JavaScript where we have to generate dynamic html let content = '<li class="list-item">' + '<div class="details">' + '<h3>{ title }</h3>' + '<p>{ description }</p>' ++ '</div>' + '</li>'; You can see the code above looks messy and difficult to read. WordPress recommends to use underscore templates.WordPress already … Continue reading Using underscore template in WordPress

Fix PHPCS errors in WordPress

Visibility must be declared on method "__construct" Add public before the class method Detected usage of a non-sanitized input variable: $_POST['xyz'] You need to sanitize it. E.g. esc_html( $_POST['xyz'] ) or sanitize_text_field( $_POST['xyz'] )  Detected usage of a possibly undefined superglobal array index: $_POST['query']. Use isset() or empty() to check Wrap it inside empty() e.g. … Continue reading Fix PHPCS errors in WordPress

Object Caching In WordPress

As a CMS, WordPress is heavily dependent on its database, and database efficiency is crucial to scaling( capability to handle increased/growing workload ) WordPress. If requests to your website generates a large number of database queries, your database servers resource can become overwhelmed. This will reduce your site’s performance and uptime. To avoid multiple database … Continue reading Object Caching In WordPress

Google Maps in React: Autocomplete Location Search | Draggable Marker | Marker Infobox

I will teach you how to integrate Google Maps in your React Project.You will also learn how to create an autocomplete location search and draggable marker. When you search the location and select one the marker will automatically move to that location and display the address in the infobox.We will use the following npm modules … Continue reading Google Maps in React: Autocomplete Location Search | Draggable Marker | Marker Infobox

File Or Image Uploads on Amazon Web Services ( AWS ) using React, Node and Express JS ( aws-sdk )

I will teach you the quickest and easiest way to upload single as well as multiple files on AWS using React js, Node js and Express js Here are the steps you will take: 1-Create an account on console.aws.amazon.com  2-Create a user and a new bucket. Note the accessKeyId and the secretAccessKey 3-Add policy to the bucket and the … Continue reading File Or Image Uploads on Amazon Web Services ( AWS ) using React, Node and Express JS ( aws-sdk )