10 October 2021

How to create flash message in Wordpress in PHP with session?

Create flash message in Wordpress in PHP.


<?php 

if(isset($_POST['submit'])){

        session_start();

$info = '<div class="success">Application has been updated successfully.</div>';

$_SESSION['flashmessage'] = $info;

exit();

}

session_start();

if(!empty($_SESSION['flashmessage'])){ 

//echo 'jassi';

echo $_SESSION['flashmessage']; 

unset( $_SESSION['flashmessage'] );

/* session_unset();

session_destroy(); */

}

?>

29 September 2021

How to create quiz timer (Left time) in PHP?

Create quiz timer in PHP. 

<!DOCTYPE html>

<html lang="en">

<body>

<center>

<div class="time" id="navbar">Time left :<span id="timer"></span></div>

<button class="button" id="mybut" onclick="myFunction()">START QUIZ</button>

</center>

<div id="myDIV" style="padding: 10px 30px;">

<form action="result.php" method="post" id="form"> 


</form>

</div>

<script>

function myFunction() {

var x = document.getElementById("myDIV");

    var b = document.getElementById("mybut");

    var x = document.getElementById("myDIV");

if (x.style.display === "none") { 

b.style.visibility = 'hidden';

x.style.display = "block";

startTimer();

}

}

window.onload = function() {

  document.getElementById('myDIV').style.display = 'none';

};

</script>

<?php

$settime = 0 . ':' . 01 . ':' . 06;

?>

 <script type="text/javascript">

document.getElementById('timer').innerHTML = '<?php echo $settime; ?>';

  //06 + ":" + 00 ;

function startTimer() {

  var presentTime = document.getElementById('timer').innerHTML;

  var timeArray = presentTime.split(/[:]+/);

  var h = timeArray[0];

  var m = timeArray[1];

  var s = checkSecond((timeArray[2] - 1));

  if(s==59){

  m=m-1

   if(m==0 && h>0){

h=h-1

m=59

  } 

  }

    document.getElementById('timer').innerHTML =

    h + ":" + m + ":" + s;

  if(h==0 && m==0 && s==0){

  //document.getElementById("form").submit();

  console.log('Time is Done.');

  if(s==0){

return true;

  }

  }

 setTimeout(startTimer, 1000);

}

function checkSecond(sec) {

  if (sec < 10 && sec >= 0) {sec = "0" + sec}; // add zero in front of numbers < 10

  if (sec < 0) {sec = "59"};

  return sec;

 // if(sec == 0 && m == 0){ alert('stop it')};

}

function checkmintue(min) {

  if (min < 10 && min >= 0) {min = "0" + min}; // add zero in front of numbers < 10

  if (min < 0) {min = "59"};

  return min;

 // if(min == 0 && h == 0){ alert('stop it')};

}

</script>

</body>

</html>

28 September 2021

How to create event time(Timmer) in PHP and Javascript?

Create event time(Timmer) in PHP and Javascript.


<?php 
/* date_default_timezone_set('Asia/Calcutta');
$timestamp = time(); */
//set hours according to the India time

$date = '2021-09-28';
$hour = '13';
$minutes = '14';
$seconds = '0';

?>
<div id="timer"></div>
<script>

//task: get timer details from the previous section and assign them to variables. 
//tip, these are associative arrays accessed as $myArray['data'] 

const countDownDate = <?php 


 echo strtotime("$date $hour:$minutes:$seconds" ) ?> * 1000;

let timeNow = <?php print(time()) ?> * 1000;

// Every second, the countdown will be updated.

let i = setInterval(function() {

 timeNow = timeNow + 1000;

// Calculate the time between now and the end of the countdown.  

let dist = countDownDate - timeNow;

// Calculate the number of days, hours, minutes, and seconds in days, hours, minutes, and seconds.

let numOfDays = Math.floor(dist / (1000 * 60 * 60 * 24));

let hr = Math.floor((dist % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));

let min = Math.floor((dist % (1000 * 60 * 60)) / (1000 * 60));

let sec = Math.floor((dist % (1000 * 60)) / 1000);

// Put the result in an element with the id="timer" attribute.  

document.getElementById("timer").innerHTML = numOfDays + "d " + hr + "h " +

min + "m " + sec + "s ";

// When the countdown is over, type some text. 

if (dist < 0) {

clearInterval(i);

document.getElementById("timer").innerHTML = "TIMER EXPIRED";

}

}, 1000);

</script>

How to create quiz timer or time countdown in PHP and Javascript?

Create quiz timer or time countdown in PHP and Javascript.


 <!DOCTYPE html>

<html lang="en">

<body>

<center>

<div class="time" id="navbar">Time left :<span id="timer"></span></div>

<button class="button" id="mybut" onclick="myFunction()">START QUIZ</button>

</center>

<div id="myDIV" style="padding: 10px 30px;">

<form action="result.php" method="post" id="form"> 


</form>

</div>

<script>

function myFunction() {

var x = document.getElementById("myDIV");

    var b = document.getElementById("mybut");

    var x = document.getElementById("myDIV");

if (x.style.display === "none") { 

b.style.visibility = 'hidden';

x.style.display = "block";

startTimer();

}

}

window.onload = function() {

  document.getElementById('myDIV').style.display = 'none';

};

</script>

<?php

$settime = 06 . ':' . 00;

?>

 <script type="text/javascript">

document.getElementById('timer').innerHTML = '<?php echo $settime; ?>';

  //06 + ":" + 00 ;

function startTimer() {

  var presentTime = document.getElementById('timer').innerHTML;

  var timeArray = presentTime.split(/[:]+/);

  var m = timeArray[0];

  var s = checkSecond((timeArray[1] - 1));

  if(s==59){m=m-1}

    document.getElementById('timer').innerHTML =

    m + ":" + s;

  if(m==0 && s==0){

  //document.getElementById("form").submit();

  console.log('Time is Done.');

  if(s==0){

return true;

  }

  }

 setTimeout(startTimer, 1000);

}

function checkSecond(sec) {

  if (sec < 10 && sec >= 0) {sec = "0" + sec}; // add zero in front of numbers < 10

  if (sec < 0) {sec = "59"};

  return sec;

  if(sec == 0 && m == 0){ alert('stop it')};

}

</script>


</body>

</html>

24 September 2021

How to play youtube video on website with youtube link in PHP?

YouTube video on website with youtube link in PHP.

<?php

$topic_youtube_link = 'https://www.youtube.com/embed/vLFi-ODflLI';

$ytarray=explode("/", $topic_youtube_link);

$ytendstring=end($ytarray);

$ytendarray=explode("?v=", $ytendstring);

$ytendstring=end($ytendarray);

$ytendarray=explode("&", $ytendstring);

$ytcode=$ytendarray[0];

?>

<ifr ame class="play-youtube" src="https://www.youtube.com/embed/<?php echo $ytcode; ?>"  title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

<?php

How to add custom meta value in edit order page in Woo-commerce in Wordpress?

Add custom meta value in edit order page in Woo-commerce in Wordpress? 


//===============add meta data on edit order page =========================
/**
 * @param $item_id
 * @param $item
 * @param $product   Product
 */
function wpcodekit_order_meta_customized_display( $item_id, $item, $product ) {
global $woocommerce, $post;
    /*
    *  The default key to "$all_meta_data" can be: _qty,_tax_class,_line_tax,_line_tax_data,_variation_id,_product_id,_line_subtotal, _line_total,_line_subtotal_tax
    */
    $all_meta_data = get_metadata( 'order_item', $item_id, "", "" );  
//print_r($product);
echo $product->get_id();
echo $order_id = $post->ID;
/* 
$order = new WC_Order($post->ID);
//to escape # from order id 
echo $order_id = trim(str_replace('#', '', $order->get_order_number())); */



    ?>
    <div class="order_data_column" style="width: 50%; padding: 0 5px;">
        <h4><?php _e( 'Customized Values' ); ?></h4>
        <?php
            echo '<p><span style="display:inline-block; width:100px;">' . __( "Item to show 01" ) . '</span><span>:&nbsp;' . "Value to show 01" . '</span></p>';
    ?>
     </div>
<?php
}


add_action( 'woocommerce_after_order_itemmeta', 'wpcodekit_order_meta_customized_display',10, 3 );

23 September 2021

How to upload file in selected folder in PHP in Wordpress?

Upload file in selected folder in PHP in Wordpress. 


   <?php

   //echo $folder =  get_stylesheet_directory_uri();

  // echo $_SERVER["DOCUMENT_ROOT"];

 extract($_POST);

 global $wpdb;

 if(isset($_POST['submit'])){

 

$filename = $_FILES["file"]["name"];

$ext = pathinfo($filename, PATHINFO_EXTENSION);

$encrypt_file= md5(str_replace(" ", "_", $filename).date("Y-m-d-h-i-s"));

$realpath = $encrypt_file.'.'.$ext;

   $tempname = $_FILES["file"]["tmp_name"];

   echo $folder =  $_SERVER["DOCUMENT_ROOT"]."/raising/wp-content/themes/twentytwenty-child/img/".$realpath;

   //echo $folder =  get_stylesheet_directory_uri()."/img/".$filename;

   move_uploaded_file($tempname,$folder);

   

 

 }


if(!empty($folder)){

?>

<img src="<?php echo get_stylesheet_directory_uri()."/img/".$realpath; ?>" width="400" height="400">

<?php

}

?>

<form action="" method="post" enctype="multipart/form-data" >

<input type="file" name="file" id="file" class="form-upl">

<input type="submit" name="submit" value="Submit">

</form>

21 August 2021

How to get product categories in product loop in Woo-commerce?

Get product categories in product loop in Woo-commerce.


add_action('woocommerce_shop_loop_item_title', 'pendingcategory');    

function pendingcategory(){

global $product;

$id = $product->get_id();

$terms = wp_get_post_terms( $id, 'product_cat' );

foreach ( $terms as $term ) {

$categories[] = $term->slug;

}

if ( in_array( 'pending', $categories ) ) {  

echo 'Pending';

}

 

20 August 2021

How to get map location dynamically in PHP?

 Get map location dynamically in PHP?



<iframe width="100%" height="400" src="https://maps.google.com/maps?q=<?php echo $city; ?>&output=embed"></iframe>


12 August 2021

How to add "wp_editor" in custom form in Wordrpess?

Add "wp_editor" in custom form in Wordrpess.





if(isset($_POST['submit'])){

print_r($_POST);

}

$editor_id = 'custom_editor_box';

$uploaded_csv = 'hello';

?>

<form action="" method="post">

<?php 

wp_editor( $uploaded_csv, $editor_id );

?>

<input type="submit" value="submit" name="submit">

</form>

<?php


How to build a tree from a flat array in PHP>

Build a tree from a flat array in PHP

 

$hello = array

  (

  array("ID" => "1","student" => "Jassi","marks" => "80","parent_id" => ""),

  array("ID" => "2","student" => "Golu","marks" => "80","parent_id" => "1"),

  array("ID" => "3","student" => "Jassi","marks" => "80","parent_id" => "1"),

  array("ID" => "4","student" => "Jai","marks" => "90","parent_id" => "1"),

  array("ID" => "5","student" => "Jassi","marks" => "85","parent_id" => "1"),

  array("ID" => "6","student" => "Ravinder","marks" => "30","parent_id" => "1"),

  array("ID" => "7","student" => "Mukesh","marks" => "45","parent_id" => "1"),

  array("ID" => "8","student" => "Ankush","marks" => "96","parent_id" => "2"),

  array("ID" => "9","student" => "Aman","marks" => "90","parent_id" => "2")

  );


function buildTree($elements, $parentId = 0) {

    $branch = array();


    foreach ($elements as $element) {

        if ($element['parent_id'] == $parentId) {

            $children = buildTree($elements, $element['ID']);

            if ($children) {

                $element['children'] = $children;

            }

            $branch[] = $element;

        }

    }


    return $branch;

}


echo '<pre>';

$tree = buildTree($hello,1);


print_r( $tree );

How to get PHP array group by key value?

“PHP array group by key value"



$hello = array
  (
  array("ID" => "1","student" => "Jassi","marks" => "80","parent_id" => ""),
  array("ID" => "2","student" => "Golu","marks" => "80","parent_id" => "1"),
  array("ID" => "3","student" => "Jassi","marks" => "80","parent_id" => "1"),
  array("ID" => "4","student" => "Jai","marks" => "90","parent_id" => "1"),
  array("ID" => "5","student" => "Jassi","marks" => "85","parent_id" => "1"),
  array("ID" => "6","student" => "Ravinder","marks" => "30","parent_id" => "1"),
  array("ID" => "7","student" => "Mukesh","marks" => "45","parent_id" => "1"),
  array("ID" => "8","student" => "Ankush","marks" => "96","parent_id" => "2"),
  array("ID" => "9","student" => "Aman","marks" => "90","parent_id" => "2")
  );



function group_by($key, $data) {
    $result = array();

    foreach($data as $val) {
        if(array_key_exists($key, $val)){
            $result[$val[$key]][] = $val;
        }else{
            $result[""][] = $val;
        }
    }

    return $result;
}


$byGroup = group_by("student", $hello);

echo '<pre>';

print_r($byGroup);

foreach($byGroup as $sub_cate=>$subarray){
//echo $sub_cate . ' ' . $subarray;


echo 'Subarray = >' . $sub_cate . '<br>';

foreach($subarray as $print){
echo $print['ID'].',';
}
echo '<br>=========================<br>';
}

10 August 2021

How To Add (Create) Pagination in WordPress?

 Add (Create) Pagination in WordPress.




<style>

.cus_pagination ul li .page-numbers {

    background: white;

    padding: 7px 11px;

    margin-left: 8px;

    text-decoration: none;

    border: 1px solid black;

    color: #000;

}

.cus_pagination ul {

    display: flex;

}


.cus_pagination span.page-numbers.current {

    background: #000;

    color: white;

}

</style>

<?php


global $wpdb;

// QUERY HERE TO COUNT TOTAL RECORDS FOR PAGINATION 

$cars = array

  (

  array("student" => "Jassi","marks" => "80"),

  array("student" => "Jai","marks" => "90"),

  array("student" => "Golu","marks" => "85"),

  array("student" => "Ravinder","marks" => "30"),

  array("student" => "Mukesh","marks" => "45"),

  array("student" => "Ankush","marks" => "96"),

  array("student" => "Aman","marks" => "90")

  );

  

 $total = count($cars);


$post_per_page = 1;

$page = isset( $_GET['cpage'] ) ? abs( (int) $_GET['cpage'] ) : 1;

$offset = ( $page * $post_per_page ) - $post_per_page;


// QUERY HERE TO GET OUR RESULTS 

//$results = $wpdb->get_results("SELECT student, marks FROM $cars LIMIT $post_per_page OFFSET $offset");

// or 

$results = array_slice( $cars, $offset, $post_per_page );


/* print_R($results);

die();


 */



// PHP FOR EACH LOOP HERE TO DISPLAY OUR RESULTS

foreach($results as $row)

 {

//print_r($row);


 echo $row['student']." => ".$row['marks']."<br>"; 

 }

// END OUR FOR EACH LOOP


?>

<?php 

echo '<div class="cus_pagination">';

echo paginate_links( array(

'base' => add_query_arg( 'cpage', '%#%' ),

'format' => '',

'prev_text' => __('&laquo;'),

'next_text' => __('&raquo;'),

'total' => ceil($total / $post_per_page),

'current' => $page,

'type' => 'list'

));

echo '</div>';

?>

28 July 2021

How to add to cart product with ajax in woocommerce?

Add to cart product with ajax in woocommerce (Without Refresh page).

<script>

jQuery(document).ready(function($) {

    $('.wishlist_add_to_cart').on('click', function(e){ 

    e.preventDefault();

$('.wishlist_preloader').css('visibility','visible');

    $thisbutton = $(this),

                $form = $thisbutton.closest('form.cart'),

                id = $thisbutton.val(),

                product_qty = $form.find('input[name=quantity]').val() || 1,

                product_id = $(this).data('product-id');

                variation_id = $form.find('input[name=variation_id]').val() || 0;

    var data = {

            action: 'ql_woocommerce_ajax_add_to_cart',

            product_id: product_id,

            product_sku: '',

            quantity: product_qty,

            variation_id: variation_id,

        };

    $.ajax({

            type: 'post',

            url: wc_add_to_cart_params.ajax_url,

            data: data,

            beforeSend: function (response) {

                $thisbutton.removeClass('added').addClass('loading');

            },

            complete: function (response) {

                $thisbutton.addClass('added').removeClass('loading');

            }, 

            success: function (response) {

                if (response.error & response.product_url) {

                    window.location = response.product_url;

                    return;

                } else { 

$('.delete_wishlist_'+ response).remove();

$('.wishlist_preloader').css('visibility','hidden');

$('.wishlist_notice_box').html('<div class="wishlist_notice_message">Product added to cart successfully.</div>');

get_wishlist_count();

                    $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $thisbutton]);

                } 

if (!$('tr').hasClass("wishlist_item")) {

$('.wp_wishlist_table tr:last').after('<tr><td colspan="6" >Not Found</td></tr>');

}

            }, 

        }); 

     }); 

});

</script> 


Paste in Function.php

add_action('wp_ajax_ql_woocommerce_ajax_add_to_cart', 'ql_woocommerce_ajax_add_to_cart'); 

add_action('wp_ajax_nopriv_ql_woocommerce_ajax_add_to_cart', 'ql_woocommerce_ajax_add_to_cart');  


function ql_woocommerce_ajax_add_to_cart() {  

    $product_id = apply_filters('ql_woocommerce_add_to_cart_product_id', absint($_POST['product_id']));

    $quantity = empty($_POST['quantity']) ? 1 : wc_stock_amount($_POST['quantity']);

    $variation_id = absint($_POST['variation_id']);

    $passed_validation = apply_filters('ql_woocommerce_add_to_cart_validation', true, $product_id, $quantity);

    $product_status = get_post_status($product_id); 

    if ($passed_validation && WC()->cart->add_to_cart($product_id, $quantity, $variation_id) && 'publish' === $product_status) { 

        do_action('ql_woocommerce_ajax_added_to_cart', $product_id);

            if ('yes' === get_option('ql_woocommerce_cart_redirect_after_add')) { 

                wc_add_to_cart_message(array($product_id => $quantity), true); 

            } 

echo $product_id;

           // WC_AJAX :: get_refreshed_fragments(); 

  

            } else { 

                $data = array( 

                    'error' => true,

                    'product_url' => apply_filters('ql_woocommerce_cart_redirect_after_error', get_permalink($product_id), $product_id));

                echo wp_send_json($data);

            }

            wp_die();

        }


How to get product detail from product id in woo-commerce?

Get product detail from product id in woo-commerce.


                $product_id = $result->post_id;
$product = wc_get_product( $product_id );
$product_link = get_permalink( $product->get_id() );

// Get Product ID
  
$product->get_id();
  
// Get Product General Info
  
$product->get_type();
$product->get_name();
$product->get_slug();
$product->get_date_created();
$product->get_date_modified();
$product->get_status();
$product->get_featured();
$product->get_catalog_visibility();
$product->get_description();
$product->get_short_description();
$product->get_sku();
$product->get_menu_order();
$product->get_virtual();
get_permalink( $product->get_id() );
  
// Get Product Prices
  
$product->get_price();
$product->get_regular_price();
$product->get_sale_price();
$product->get_date_on_sale_from();
$product->get_date_on_sale_to();
$product->get_total_sales();
  
// Get Product Tax, Shipping & Stock
  
$product->get_tax_status();
$product->get_tax_class();
$product->get_manage_stock();
$product->get_stock_quantity();
$product->get_stock_status();
$product->get_backorders();
$product->get_sold_individually();
$product->get_purchase_note();
$product->get_shipping_class_id();
  
// Get Product Dimensions
  
$product->get_weight();
$product->get_length();
$product->get_width();
$product->get_height();
$product->get_dimensions();
  
// Get Linked Products
  
$product->get_upsell_ids();
$product->get_cross_sell_ids();
$product->get_parent_id();
  
// Get Product Variations and Attributes
 
$product->get_children(); // get variations
$product->get_attributes();
$product->get_default_attributes();
$product->get_attribute( 'attributeid' ); //get specific attribute value
  
// Get Product Taxonomies
  
$product->get_categories();
$product->get_category_ids();
$product->get_tag_ids();
  
// Get Product Downloads
  
$product->get_downloads();
$product->get_download_expiry();
$product->get_downloadable();
$product->get_download_limit();
  
// Get Product Images
  
$product->get_image_id();
$product->get_image();
$product->get_gallery_image_ids();
  
// Get Product Reviews
  
$product->get_reviews_allowed();
$product->get_rating_counts();
$product->get_average_rating();
$product->get_review_count();

21 July 2021

How to add google reCAPTCHA in form in PHP?

Add google reCAPTCHA in form in PHP





<html>
<head>
  <script src='https://www.google.com/recaptcha/api.js' async defer></script>
</head>
<body>
<?php 
if(isset($_POST['submit'])){
$captcha;

        if(isset($_POST['g-recaptcha-response'])){
          $captcha=$_POST['g-recaptcha-response'];
        }
        if(!$captcha){
          echo 'Please check the the captcha form.';
          exit;
        }
        $secretKey = "<!==== Secret key ====!>";
        $ip = $_SERVER['REMOTE_ADDR'];
        // post request to server
        $url = 'https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secretKey) .  '&response=' . urlencode($captcha);
        $response = file_get_contents($url);
        $responseKeys = json_decode($response,true);
        // should return JSON with success as true
        if($responseKeys["success"]) {
                echo 'Thanks for posting';
echo $_POST['name'];
        } else {
                echo 'You are spammer ! Get the @$%K out';
        }

}
?>
<form action="" method="post">
<input type="text" name="name" placeholder="name" value="Hello World">
<div class="g-recaptcha" data-sitekey="<!==== Site key ====!>"></div>
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

How to make a section sticky in specific div (Section) in HTML/CSS?

Make a section sticky in specific div (Section) in HTML/CSS.






<style>
.scrollsec {
    height: fit-content;
    line-height: 50px;
    margin-top: 10px;
    font-size: 30px;
    padding-left: 10px;
    position: -webkit-sticky;
    position: sticky;
    top: 104px;
}
</style>

20 July 2021

How to create parallax effect in website?

Create parallax effect in website.





<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=500" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.8/ScrollMagic.js" integrity="sha512-UgS0SVyy/0fZ0i48Rr7gKpnP+Jio3oC7M4XaKP3BJUB/guN6Zr4BjU0Hsle0ey2HJvPLHE5YQCXTDrx27Lhe7A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<style>

.section-wipes {
    height: 100%;
    width: 100%;
    background-image: none;
}
b {
    color: green;
    font-size: 44px;
    display: flex;
    margin: auto;
    align-items: center;
    justify-content: center;
    align-items: center;
}



body, html {
height: 100%;
padding: 0px;
margin: 0px;
}

.panel {
height: 100%;
width: 100%;
}


</style>
</head>
<body>


<body  class="section-wipes">
<section class="panel" style="background-color:blue">
<b>ONE</b>
</section>
<section class="panel " style="background-color:pink">
<b>TWO</b>
</section>
<section class="panel " style="background-color:green">
<b>THREE</b>
</section>
<section class="panel " style="background-color:red">
<b>FOUR</b>
</section>
<script>
$(function () { // wait for document ready
// init
var controller = new ScrollMagic.Controller({
globalSceneOptions: {
triggerHook: 'onLeave',
duration: "200%" // this works just fine with duration 0 as well
// However with large numbers (>20) of pinned sections display errors can occur so every section should be unpinned once it's covered by the next section.
// Normally 100% would work for this, but here 200% is used, as Panel 3 is shown for more than 100% of scrollheight due to the pause.
}
});

// get all slides
var slides = document.querySelectorAll("section.panel");

// create scene for every slide
for (var i=0; i<slides.length; i++) {
new ScrollMagic.Scene({
triggerElement: slides[i]
})
.setPin(slides[i], {pushFollowers: false})
.addIndicators() // add indicators (requires plugin)
.addTo(controller);
}
});
</script>
</body>


</body>
</html>

09 July 2021

How to create Sign-In profile and Sign-Out mini Drop-Down?

 function shortcut_menu(){

?>


<style>

.cus-dropbtn {

    color: black;

    padding: 16px;

    border: none;

    background: white !important;

    text-decoration: none !important;

    font-size: 15px !important;

    text-transform: capitalize;

}

.cus-dropdown {

    position: relative;

    display: inline-block;

    height: 32px;

}


.cus-dropdown-content {

    display: none;

    position: absolute;

    background-color: #f1f1f1;

    min-width: 160px;

    box-shadow: 0px 8px 16px 0px rgb(0 0 0 / 20%);

    z-index: 120;

    top: 33px;

}


.cus-dropdown-content a {

  color: black;

  padding: 12px 16px;

  text-decoration: none;

  display: block;

}


.cus-dropdown-content a:hover {background-color: #f1f1f1;}


.cus-dropdown:hover .cus-dropdown-content {display: block;}


.cus-dropdown:hover .cus-dropbtn {background-color: white;}



.cus-dropdown-content:after {

bottom: 100%;

left: 50%;

border: solid transparent;

content: "";

height: 0;

width: 0;

position: absolute;

pointer-events: none;

}




.cus-dropdown-content:after {

    border-color: rgba(213, 213, 213, 0);

    border-bottom-color: #d5d5d5;

    border-width: 9px;

    margin-left: -59px;

}


</style> 

</head>


<?php

global $current_user;

wp_get_current_user() ;

$username = $current_user->user_login;

$user_id = get_current_user_id();

$wcfmuser = wcfm_is_vendor( $user_id );

 if(wcfm_is_vendor( $user_id )){

$profile_url = site_url() . '/store-manager'; 

}

else{

$profile_url = site_url() . '/your-account';

}

 

if ( is_user_logged_in() ) {

?>

<div class="cus-dropdown">

  <a href="<?php echo site_url(); ?>/signin/" class="cus-dropbtn"><!--<i class="fas fa-user"></i> Hi ---><?php echo $username; ?></a>

  <div class="cus-dropdown-content">

    <a href="<?php echo $profile_url; ?>">Profile</a>

    <a href="<?php echo wp_logout_url( site_url() ); ?>">Sign Out</a>

  </div>

</div>

<?php

} else {

?>

<div class="cus-dropdown">

  <a href="<?php echo site_url(); ?>/signin/" class="cus-dropbtn"><i class="fas fa-user"></i> Sign In</a>

</div>

<?php

}

?>





<?php 

}

//add_action('wp_head', 'shortcut_menu'); 

add_shortcode('get_shortcut_menu', 'shortcut_menu'); 

03 July 2021

How to create custom product review section in woocommerce in WCFM?

Create custom  product review section in woocommerce in WCFM?





Paste in function.php

function fetch_vendor_product_reviews(){


// print_R($_POST);

$post_order_num = $_POST['post_order'];

$user_id = $_POST['store_id'];

$page = $_POST['page_num'];

if(empty($page)){

$page = 1;

}

if(empty($post_order_num) || $post_order_num == 1){

$post_order = 'DESC';

}

else{

$post_order = 'ASC';

}


if(!empty($user_id)){


$countreviews = get_comments(array(

'post_author'      => $user_id, 

        'status'   => 'approve',

        'post_status' => 'publish',

        'post_type'   => 'product',

        'count' => true

    ));

if($countreviews>0){

  ?>

<!-- filter section start -->

<section class="filter-home-product">

<div class="container">

<div class="row">

<div class="col-lg-3 col-md-3 col-sm-12">

<div class="write-review pull-left">

<span><?php echo $countreviews; ?> Reviews</span>

</div>

</div>

<div class="col-lg-9 col-md-9 col-sm-12">

<div class="write-review pull-left">

<span>Write a Review</span>

</div>

<div class="write-review pull-right">

<ul>

<li>

<div> 

<span>Sort By: </span>

<select name="price" class="post_order" id="price">

<option value="1" <?php if($post_order_num ==1){ echo 'selected'; } ?> >Newest</option>

<option value="2" <?php if($post_order_num ==2){ echo 'selected'; } ?>>Oldest</option>

</select> 

</div>

</li>

</ul>

</div>

</div>

</div>

<?php


$limit = 2;

$offset = ($page * $limit) - $limit;

$pages = ceil($countreviews/2);


$comment_args = array( 

                'post_author'      => $user_id, 

                'status'      => 'approve', 

                'post_status' => 'publish', 

                'post_type'   => 'product',

                'offset'   => $offset,

                'number'   => $limit,

'orderby'=> 'ID', 

'order'   => $post_order

        );

$comments = get_comments($comment_args);

//print_R($comments);

if ( ! $comments ) return '';

/* echo '<pre>';

print_R($comments); */

foreach ( $comments as $comment ) {  

//echo $comment->comment_author; 

$comment_post_ID =  $comment->comment_post_ID; 

$comment_user_id = $comment->user_id; 

$product = wc_get_product( $comment_post_ID );

// if($comment_user_id==$user_id){

// if(get_comment_author($comment->comment_post_ID)==$user_id){

$rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) );

?>

<div class="row" style="margin-top:50px;">

<div class="col-lg-3 col-md-3 col-sm-12">

<div class="filter-product">

<div class="filter-author">

<i class="fa fa-user-circle"></i>

<h4><?php echo $comment->comment_author; ?></h4>

</div>

<div class="product-pics">

<?php  echo get_the_post_thumbnail($comment_post_ID); ?>

</div>

<div class="product-disc">

<h3><a href="<?php echo get_permalink( $comment_post_ID ); ?>"><?php echo $comment->post_title; ?></a></h3>

<p><?php echo get_woocommerce_currency_symbol() .''. $product->get_price(); ?></p>

</div>

</div>

</div>

<div class="col-lg-9 col-md-9 col-sm-12">

<div class="filter-product">

<div class="review-star text-center" style="text-align:left !important;">

<?php echo wc_get_rating_html( $rating ); ?>

<h3 style="font-weight:700;margin:20px 0 30px;">amazing!!</h3>

<p><?php echo $comment->comment_content; ?></p>

<div class="filter-product-btn">

<div class="write-review pull-left">

<p><i style="color:#387b50;" class="fa fa-check"></i>Recommends this project</p>

</div>

<div class="write-review pull-right">

<span>Did you find this helpful?</span>

<span class="up-down"><i class="fas fa-caret-up"></i>10</span>

<span class="up-down"><i class="fa fa-caret-down"></i>3</span>

</div>

</div>

</div>

</div>

</div>

</div>

<?php

}

?>

<div class="row">

<div class="col-lg-12 col-md-12 col-sm-12">

<div class="pagination-block">

<?php if($page != 1){

?>

<a class="next page-numbers" data-page="<?php echo $pages-1; ?>" href=""><i class="fas fa-angle-left" aria-hidden="true"></i></a>

<?php 

}

?>

<?php

if($pages != 1){

for($i=1; $i <= $pages; $i++)

{

?>

<span class="page-numbers <?php if($page==$i){ echo 'current'; } ?>" data-page="<?php echo $i; ?>" ><?php echo $i; ?></span>

<?php

}

}

?>

<?php if($page != $pages){

?>

<a class="next page-numbers" data-page="<?php echo $pages; ?>" href=""><i class="fas fa-angle-right" aria-hidden="true"></i></a>

<?php

}

?>

                       </div>

</div>

</div>

</div>

</section>


<?php

 }

 }


die();

}

add_action('wp_ajax_fetch_vendor_product_reviews','fetch_vendor_product_reviews');

add_action('wp_ajax_nopriv_fetch_vendor_product_reviews','fetch_vendor_product_reviews');






function vendor_product_reviews(){

global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;

$store_id = '';

if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) { $store_id = absint($attr['id']); }

if (  wcfm_is_store_page() ) {

$wcfm_store_url = get_option( 'wcfm_store_url', 'store' );

$store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );

$store_id  = 0;

if ( !empty( $store_name ) ) {

$store_user = get_user_by( 'slug', $store_name );

}

$store_id  = $store_user->ID;

}

?>

<!-- Bootstrap CSS -->


<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">

    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/custom-css/bootstrap.min.css">

<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/custom-css/bootstyle.css">

<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">

<div class="review_section_outer_box">

<div class="review_preloader">

<img src="<?php echo get_template_directory_uri(); ?>/assets/images/reivewloader.gif">

</div>

<div class="custom_review_box">

</div>

</div>


<script>

jQuery(document).ready(function($){

fetch_vendor_product_reviews(); 

$('body').on('change','.post_order',function(e){

e.preventDefault();

//$('.post_order').change(function(){

fetch_vendor_product_reviews(); 

});



$('body').on('click','.page-numbers',function(e){

e.preventDefault();

//$('.post_order').change(function(){

var page_num = $(this).data('page');

//alert(page_num);

fetch_vendor_product_reviews(page_num); 

});

 function fetch_vendor_product_reviews(page_num){

    var post_order = $('.post_order').val();

    var store_id = "<?php echo $store_id; ?>";

$('.review_preloader').css('display','flex')

var ajax =  "<?php echo admin_url('admin-ajax.php'); ?>";

    var data = {

'action' : "fetch_vendor_product_reviews",

'post_order' : post_order,

'store_id' : store_id,

'page_num' : page_num

    } 

    $.post(ajax,data,function(response){

//$("#response").html(response);

//console.log(response);

$('.custom_review_box').html(response);

$('.review_preloader').css('display','none')

    });

   }

    

});

</script>

<?php

 }

//add_action('wp_head','vendor_product_reviews');

add_shortcode('get_vendor_product_reviews', 'vendor_product_reviews'); 


Paste anywhere

<?php echo do_shortcode('[staff_detail]'); ?>



How to get store data from WCFM(Best Multi Vendor Marketplace) Plugin?

 Get store data from WCFM(Best Multi Vendor Marketplace) Plugin.


global $WCFM, $WCFMmp, $wp, $WCFM_Query, $post;

$store_id = '';

if ( isset( $attr['id'] ) && !empty( $attr['id'] ) ) { $store_id = absint($attr['id']); }

if (  wcfm_is_store_page() ) {

$wcfm_store_url = get_option( 'wcfm_store_url', 'store' );

$store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );

$store_id  = 0;

if ( !empty( $store_name ) ) {

$store_user = get_user_by( 'slug', $store_name );

}

$store_id    = $store_user->ID;

}

$user_id = $store_id; 

$vendor_data = get_user_meta( $user_id, 'wcfmmp_profile_settings', true );

$street_1 = $vendor_data['address']['street_1'];

$street_2 = $vendor_data['address']['street_2'];

$city     = $vendor_data['address']['city'];

$zip      = $vendor_data['address']['zip'];

$country  = $vendor_data['address']['country'];

$state    = $vendor_data['address']['state'];

$store_email    = $vendor_data['store_email'];

$phone    = $vendor_data['phone'];

$store_location    = $vendor_data['store_location'];

How to get review bar in Woo-commerce in wordpress.

Get review bar in Woo-commerce in wordpress.


 function get_all_products() {

    $ps = new WP_Query( array(
        'post_type' => 'product',
        'post_status' => 'publish',
'author' => 130,
        'posts_per_page' => '-1'
    ) );
    $arr = array();
    while($ps->have_posts()){
      $ps->the_post();
      $arr[] = get_the_ID();
    }
    return $arr;
}



function get_store_bar_rating(){
  $products = get_all_products();
  foreach ($products as $key => $value) {
$product_id = $value;
$get_rating_count = get_post_meta( $product_id, '_wc_rating_count', true );
   if(is_array($get_rating_count)){
foreach($get_rating_count as $key=>$value){
if($key==1){
$onerating += $value;
}
if($key==2){
$tworating += $value;
}
if($key==3){
$threerating += $value;
}
if($key==4){
$fourrating += $value;
}
if($key==5){
$fiverating += $value;
}
}
   } 
  }


if(empty($onerating)){
$onerating = 0;
}
if(empty($tworating)){
$tworating = 0;
}
if(empty($threerating)){
$threerating = 0;
}
if(empty($fourrating)){
$fourrating = 0;
}
if(empty($fiverating)){
$fiverating = 0;
}

$totalrating = $onerating + $tworating + $threerating + $fourrating + $fiverating;

/*    echo '1 =' . $onerating;
   echo '<br>';
   echo '2 =' . $tworating;
   echo '<br>';
   echo '3 =' . $threerating;
   echo '<br>';
   echo '4 =' . $fourrating;
   echo '<br>';
   echo '5 =' . $fiverating;
   echo '<br>'; */
$onewidth   = $onerating * 100 / $totalrating;
$twowidth   = $tworating * 100 / $totalrating;
$threewidth = $threerating * 100 / $totalrating;
$fourwidth  = $fourrating * 100 / $totalrating;
$fivewidth  = $fiverating * 100 / $totalrating;
   
?>
<style>

.review_box_con{

}
.review_row{
  display : flex;
  margin-bottom:20px
}
.outer_review_bar{
  width:100%;
  height:30px;
  background:#f1f1f1;
  margin-left : 70px;
  overflow:hidden;
}
.inner_review_bar{
  height:30px;
  background:#F6C1B8;
}
.review_star_tx {
    font-size: 20px;
    font-weight: 500;
    display: inline-block;
    width: 87px;
    text-align: center;
    line-height: 28px;
}
span.total_bar_rating {
    font-size: 21px;
    font-weight: 700;
    margin-bottom: 9px;
    box-sizing: border-box;
    display: inline-block;
}
</style>
<div class="review_box_con">
<span class="total_bar_rating"><?php if(empty($totalrating)){ echo '0'; }else { echo $totalrating; } ?> reviews</span> 
    <div class="review_row">
      <span class="review_star_tx">5 Star</span>
    <div class="outer_review_bar">
      <div class="inner_review_bar" style="width:<?php if(!empty($fivewidth)){ echo $fivewidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($fiverating)){ echo '0'; }else { echo $fiverating; } ?></span>
    </div>
      <div class="review_row">
      <span class="review_star_tx">4 Star</span>
    <div class="outer_review_bar">
       <div class="inner_review_bar"  style="width:<?php if(!empty($fourwidth)){ echo $fourwidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($fourrating)){ echo '0'; }else { echo $fourrating; } ?></span>
    </div>
      <div class="review_row">
      <span class="review_star_tx">3 Star</span>
    <div class="outer_review_bar">
       <div class="inner_review_bar"  style="width:<?php if(!empty($threewidth)){ echo $threewidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($threerating)){ echo '0'; }else { echo $threerating; } ?></span>
    </div>
      <div class="review_row">
      <span class="review_star_tx">2 Star</span>
    <div class="outer_review_bar">
       <div class="inner_review_bar"  style="width:<?php if(!empty($twowidth)){ echo $twowidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($tworating)){ echo '0'; }else { echo $tworating; } ?></span>
    </div>
      <div class="review_row"> 
      <span class="review_star_tx">1 Star</span>
    <div class="outer_review_bar">
       <div class="inner_review_bar"  style="width:<?php if(!empty($onewidth)){ echo $onewidth .'%'; }else { echo '0'; } ?>">
      </div>      
    </div>
    <span class="review_star_tx" ><?php if(empty($onerating)){ echo '0'; }else { echo $onerating; } ?></span>
    </div>
  
</div>

<?php
 }
add_shortcode('store_bar_rating', 'get_store_bar_rating'); 
 
 

User it anywhere

<?php echo do_shortcode('[store_bar_rating]'); ?>
 

21 June 2021

How to create floating animation in HTML/CSS?

 Create floating animation in HTML/CSS.


.floating_x {

animation-name: floating_x;

animation-duration: 6s;

animation-iteration-count: infinite;

animation-timing-function: ease-in-out;

}


@keyframes floating_x {

from {

transform: translate(0px, 0px)

}

65% {

transform: translate(15px, 0px)

}

to {

transform: translate(0px, 0px)

}

}


.floating_y {

animation-name: floating_y;

animation-duration: 4s;

animation-iteration-count: infinite;

animation-timing-function: ease-in-out;

}


@keyframes floating_y {

from {

transform: translate(0px, 0px)

}

65% {

transform: translate(0px, -20px)

}

to {

transform: translate(0px, 0px)

}

}


.floating_y2 {

animation-name: floating_y2;

animation-duration: 4s;

animation-iteration-count: infinite;

animation-timing-function: ease-in-out;

animation-delay: 1s

}


@keyframes floating_y2 {

from {

transform: translate(0px, 0px)

}

50% {

transform: translate(0px, -20px)

}

to {

transform: translate(0px, 0px)

}

}


.floating_y3 {

animation-name: floating_y3;

animation-duration: 5s;

animation-iteration-count: infinite;

animation-timing-function: ease-in-out

}


@keyframes floating_y3 {

from {

transform: translate(0px, 0px)

}

65% {

transform: translate(0px, -20px)

}

to {

transform: translate(0px, 0px)

}

}

18 June 2021

How to convert blob url into blob source code in jquery.

 Convert blob url into blob source code in jQuery


jQuery('.save_video_rec').click(function(){
        
        // blob url
        var videoblob = $('.j-video_result').attr('src');
        var blobUrl = videoblob;
        alert(blobUrl);
        var xhr = new XMLHttpRequest;
        xhr.responseType = 'blob';

        xhr.onl oad = function() {
        var recoveredBlob = xhr.response;

        var reader = new FileReader;

        reader.onl oad = function() {
         var blobAsDataUrl = reader.result;
        //  window.location = blobAsDataUrl;
        //    $('.audiovalue').val(blobAsDataUrl);
            alert(blobAsDataUrl);
        };

        reader.readAsDataURL(recoveredBlob);
        };

        xhr.open('GET', blobUrl);
        xhr.send();
        
    });

22 May 2021

How to redirect after checkout in woo-commerce in Wordpress.

Redirect after checkout in woo-commerce in Wordpress. 


Paste in function.php

/*

Redirect loggedin user to order details page

*/

if(is_user_logged_in())

{

add_action( 'template_redirect', 'woocommerce_redirect_after_checkout' );

}

function woocommerce_redirect_after_checkout() {

global $wp;

if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {

$redirect_url = home_url().'/my-account/view-order/'.$wp->query_vars['order-received'] ;


wp_redirect($redirect_url );


exit;

}

}


How to create custom guest popup for checkout with wordpress menu in wordpress.

Create custom guest popup for checkout with wordpress menu in wordpress.

Paste in function.php

function override_checkout_email_field( $fields ) {
global $wpdb;
  $popup_id = $_COOKIE['popup_id'];
global $wpdb;
$tablename = $wpdb->prefix . "guest_users";
$result = $wpdb->get_results ("SELECT * FROM $tablename WHERE id=$popup_id");
foreach ( $result as $print )   {

}
$survey_email = $print->email;
$survey_phone = $print->phone;
    global $woocommerce;
    //$survey_email = $woocommerce->session->get('survey_email');
    if(!is_null($survey_email)) {
      $fields['billing']['billing_email']['default'] = $survey_email;
    }
     if(!is_null($survey_phone)) {
      $fields['billing']['billing_phone']['default'] = $survey_phone;
    } 
    return $fields;
}

add_filter( 'woocommerce_checkout_fields' , 'override_checkout_email_field' );


// Show the popup to fetch email and phone number and store in the database




function guest_popup(){
$popup_id = $_COOKIE['popup_id'];
if(isset($_POST['guest_popup_bt'])){
$email = $_POST['email'];
$phone = $_POST['phone'];
date_default_timezone_set('Asia/Kolkata');
$date = date('d-m-Y h:i:s a');
global $wpdb;
$table_name = $wpdb->prefix . "guest_users";
$wpdb->insert($table_name, array('email' => $email, 'phone' => $phone, 'created_at' => $date) ); 
$lastid = $wpdb->insert_id;
if(!empty($lastid)){
//setcookie('popup_id', $lastid, strtotime('+1 day'), COOKIEPATH, COOKIE_DOMAIN);
setcookie('popup_id', $lastid, strtotime("+1 year"), COOKIEPATH, COOKIE_DOMAIN);
if ( ! WC()->cart->get_cart_contents_count() == 0 ) { 
wp_redirect(site_url().'/checkout');
}else{
wp_redirect(site_url().'/shop');
}
}
}
?>
<?php
if(!is_user_logged_in() && is_cart() && empty($popup_id)){
?>
<style>
.popup-container {
    width: 100%;
    height: 100vh;
    background-color: #000000bf;
    position: fixed;
    display: flex;
    justify-content: Center;
    align-items: center;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 9999999;
    left: 0;
}

.popup-box input[type="email"],input[type="number"] {
    width: 100%;
    font-size: 15px;
    padding: 7px 7px;
}
input.guest_popup_bt {
    padding: 5px 16px;
    background: #000;
    border: #000;
    color: white;
    font-weight: 400;
    font-size: 16px;
}
.form-filed-box {
    margin-top: 10px;
}
.popup-box h4 {
    margin: 0;
    font-size: 17px;
    text-align: center;
    font-weight: 400;
    letter-spacing: 1px;
    margin-bottom: 12px;
}
.popup-box {
    padding: 59px 37px;
    background: white;
    border-radius: 9px;
    width: 386px;
position:relative;
}

.popup_close_bt {
    background: #000;
    color: White;
    position: absolute;
    right: -15px;
    top: -15px;
    border-radius: 200%;
    width: 30px;
    height: 30px;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
cursor:pointer;
}
</style>
<script>
jQuery(document).ready(function($){
$('.popup_close_bt').click(function(){
$('.popup-container').css('display','none');
});

if (typeof $.cookie('popup_id') === 'undefined'){

$('.checkout-button').click(function(e){
e.preventDefault;
jQuery('.popup-container').css('display','flex');
return false;
});
}
});
</script>
<div class="popup-container">
<div class="popup-box">
<div class="popup_close_bt">X</div>
<form action="" method="post">
<h4>Please enter the following detail to move forward</h4>
<div class="form-filed-box">
<label>Email</label>
<input type="email" name="email" >
</div>
<div class="form-filed-box">
<label>Phone no.</label>
<input type="text" name="phone" >
</div>
<div class="form-filed-box">
<input type="submit" name="guest_popup_bt" class="guest_popup_bt" value="Submit">
</div>
</form>
</div>
</div>
<?php
}
}
add_action('wp_head','guest_popup');


add_action("admin_menu", "addMenu");

function addMenu() {
    add_menu_page("Guest Info", "Guest Info", "edit_posts",
        "guest-popup", "displayPage", null,10);
}

add_filter("custom_menu_order", "allowMenuStructure");
add_filter("menu_order", "loadMenuStructure");

function displayPage() {
?>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.2.2/css/buttons.dataTables.min.css">



<script src="https://code.jquery.com/jquery-1.12.3.js"></script>
<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.flash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
<script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script>
<script src="https://cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js"></script>  



<script>

$(document).ready(function() {
    $('#example').DataTable( {
      /*   dom: 'Bfrtip',
        buttons: [
            'copy', 'excelFlash', 'excel', 'pdf', 'print',{
            text: 'Reload',
            action: function ( e, dt, node, config ) {
                dt.ajax.reload();
            }
        }
        ] */
    } );
} );

</script>


<table id="example" class="display nowrap" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>S.r</th>
                <th>Date</th>
                <th>Email</th>
                <th>Phone</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>S.r</th>
                <th>Date</th>
                <th>Email</th>
                <th>Phone</th>
            </tr>
        </tfoot>
        <tbody>
<?php
global $wpdb;
$tablename = $wpdb->prefix . "guest_users";
$result = $wpdb->get_results ("SELECT * FROM $tablename order by Id DESC");
//print_r($result);
$i = 1 ;
foreach ( $result as $print )   {
?>
            <tr>
                <td><?php echo $i; ?></td>
                <td><?php echo $print->created_at; ?></td>
                <td><a href="mailto:<?php echo $print->email; ?>"><?php echo $print->email; ?></a></td>
                <td><a href="tel:<?php echo $print->phone; ?>"><?php echo $print->phone; ?></a></td>

            </tr>
<?php
$i++;
}
?>
        </tbody>
    </table>
<?php
}

How to add re-captcha v3 on all Elementor forms using coding?

 Add re-captcha v3 on all Elementor forms using coding add_action('wp_footer',function(){     ?> <script src="https://www...