Posts

Create a shortcode for custom page template

Adding the following code into your theme's "function.php" file:       function my_form_shortcode() {         ob_start();         get_template_part('page-pack-unpack-quote');         $content = ob_get_clean();         return $content;       }      add_shortcode('my_form_shortcode', 'my_form_shortcode'); Here, 'page-pack-unpack-quote' is your template file name. In page editor write : [my_form_shortcode]

How do you prevent a form from resubmitting when the page is refreshed?

Use Javascript This method is quite easy and blocks the pop up asking for form resubmission on refresh once the form is submitted. Just place this line of javascript code at the footer of your file and see the magic. Code:        <script>           if ( window.history.replaceState ) {           window.history.replaceState( null, null, window.location.href );         }     </script>

Sql useful quiries

Image
      Today's enquiry SELECT * FROM `enquiry` WHERE `en_date` >= date('Y-m-d'). ' 00:00:00';          Tomorrow's enquiry SELECT * FROM `enquiry` WHERE `en_servicedate` = date('Y-m-d', strtotime(date("Y-m-d") . " +1 day")). ' 00:00:00';       Yesterday's enquiry SELECT * FROM `enquiry` WHERE `en_date` >= date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))). ' 00:00:00' AND `en_date` <= date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))). ' 23:59:59';       This Month's booking SELECT * FROM `enquiry` WHERE `qualified_date` >= date('Y-m-01') . ' 00:00:00' AND `qualified_date` <= date('Y-m-d') . ' 23:59:59';       Current date to previous year month (ex- 21-4-2018 to 1-8-2017) SELECT * from enquiry where en_date >= date_add(date_ad...

on_sent_ok not working in Contact Form 7 version 5.0.2

Image
In Contact Form 7, there are several Additional Settings available to add extra functionality to your forms. One of these additional settings was on_sent_ok. But it is not work on version 5.0.2 Instead of this, Using Contact Form 7 Controls  plugin the task becomes fairly simple. Once you install and activate the plugin, a Customize tab will appear in each one of your Contact Form 7 forms. Then all you have to do is simply check the option for Google Analytics at the very bottom. Alternative way to use Global redirect via WordPress functions: This option will utilize a WordPress function which automatically adds the JavaScript into your WordPress footer. Simply open your function.php file then copy and paste the code below.       add_action( 'wp_footer', 'redirect_cf7' );       function redirect_cf7() { ?>       < script type = "text/javascript" >   ...

Autofill forms

 Remove autofill field in form:  Use autocomplete="cc-blank" into input html attribute.

PHPExcel Tricks

=> Date format conversion in PHP Excel: - When import excel file you have other date format and save date like database format (eg. 17-11-17 into 2017-11-17) you have write below code:  $BookingMade = " 17-11-17 "; $BookingmadeDate = date('Y-m-d', PHPExcel_Shared_Date::ExcelToPHP($BookingMade)); Output: 2017-11-17

Datatable Tricks

=> In datatable redirect baseurl when session is expired:    - In datable.js file write following code:  "data": function (d) {                 $.getJSON('contacts/ajaxData',myData, function (json) {                     if (json.expired == '1') {                         window.location = BASE_URL;                     }                 });                 return  $.extend(d, myData);          ...