18 March 2026

How to create youtube videos slider with play and pause option in wordpress?

Create youtube videos slider with play and pause option in wordpress

youtube videos slider


Use this shortcode:-[punjab_today]


function my_youtube_owl_slider($content) {
if (strpos($content, '[youtube_slider]') === false) return $content;

$channel_id = 'UCFSdmqI8stLd4NuOkKTDlMw';
$rss_url = "https://www.youtube.com/feeds/videos.xml?channel_id=" . $channel_id;

$feed = @simplexml_load_file($rss_url);
if (!$feed) return str_replace('[youtube_slider]', '', $content);

ob_start();
?>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css">
<style>
.yt-slider-wrapper { margin: 20px 0; min-height: 250px; }
.yt-owl .item { background: #000; border-radius: 12px; overflow: hidden; height: 230px; position: relative; }
.yt-player-el { width: 100%; height: 100%; display: block; }
.yt-nav { text-align: center; margin-top: 15px; }
.yt-nav button { background: #000000; color: #fff; border: none; padding: 8px 18px; cursor: pointer; border-radius: 0px; font-weight: 600; margin: 0 5px; }
.yt-nav button:hover {
background: #edb500;
}
.latestNewsVideosTitle {
color: #000000;
font-size: 22px !important;
line-height: 1.2 !important;
font-weight: 900 !important;
border-bottom: 2px solid #000;
padding-bottom: 9px;
display: inline-block;
margin: 0px;
margin-bottom: 25px;
}
</style>
<div class="yt-slider-wrapper">
<h3 class="latestNewsVideosTitle">Latest News Videos</h3>
<div class="yt-owl owl-carousel">
<?php
$count = 0;
$unique_prefix = 'yt_' . time(); // Ensures unique IDs even if page is reloaded via AJAX
foreach ($feed->entry as $entry):
if ($count >= 10) break;
$video_id = (string) $entry->children('yt', true)->videoId;
$p_id = $unique_prefix . '_' . $count;
?>
<div class="item">
<div id="<?php echo $p_id; ?>" class="yt-player-el" data-video-id="<?php echo esc_attr($video_id); ?>"></div>
</div>
<?php
$count++;
endforeach;
?>
</div>
<div class="yt-nav">
<button class="yt-prev"></button>
<button class="yt-next"></button>
</div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
<script src="https://www.youtube.com/iframe_api"></script>

<script>
(function($){
var players = [];

function initPlayers() {
$('.yt-player-el').each(function() {
var $el = $(this);
if ($el.hasClass('yt-ready')) return; // Don't re-init if already done

var player = new YT.Player(this.id, {
height: '260',
width: '100%',
videoId: $el.data('video-id'),
playerVars: { 'rel': 0, 'enablejsapi': 1 },
events: {
'onStateChange': function(event) {
if (event.data === YT.PlayerState.PLAYING) {
players.forEach(function(p) {
if (p !== event.target && typeof p.pauseVideo === 'function') p.pauseVideo();
});
}
}
}
});
players.push(player);
$el.addClass('yt-ready');
});
initCarousel();
}

function initCarousel() {
var $slider = $('.yt-owl');
if ($slider.hasClass('owl-loaded')) return;

$slider.owlCarousel({
loop: false,
margin: 15,
nav: false,
dots: false,
responsive: { 0:{items:1}, 600:{items:2}, 1000:{items:3} }
});

$('.yt-next').off().on('click', function() { $slider.trigger('next.owl.carousel'); });
$('.yt-prev').off().on('click', function() { $slider.trigger('prev.owl.carousel'); });
}

// Handle the YouTube API state
window.onYouTubeIframeAPIReady = function() {
initPlayers();
};

// If API is ALREADY loaded (second time showing), fire immediately
$(document).ready(function() {
if (typeof YT !== 'undefined' && YT.loaded) {
initPlayers();
}
});

})(jQuery);
</script>

<?php
$html = ob_get_clean();
return str_replace('[youtube_slider]', $html, $content);
}
add_filter('the_content', 'my_youtube_owl_slider', 99);

23 October 2025

How to run google search console request submission by UI vision IDE automate?

 Run google search console request submission by UI vision IDE automate?


Source View --- Json Code


{
  "Name": "DemoCsvReadArray",
  "CreationDate": "2025-10-23",
  "Commands": [
    {
      "Command": "executeScript_Sandbox",
      "Target": "return [\n'https://freshnewnews.com/2026-fifa-world-cup-final-new-jersey-venue-predictions/',\n'https://freshnewnews.com/big-ears-festival-2026-knoxville-music-art-experience/',\n'https://freshnewnews.com/coachella-2026-your-ultimate-guide-to-headliners-dates-and-indio-music/',\n'https://freshnewnews.com/lady-gaga-mayhem-ball-tour-2026-austin-show-details-ticket-information/',\n'https://freshnewnews.com/90s-con-hartford-2026-the-ultimate-nostalgia-convention-guide/',\n'https://freshnewnews.com/route-66-centennial-2026-your-ultimate-historic-road-trip-guide/',\n'https://freshnewnews.com/america-250-philadelphia-museums-parades-birthday-bash-2026/'\n];",
      "Value": "urlArray",
      "Description": "All URLs to submit for indexing"
    },
    {
      "Command": "open",
      "Target": "https://search.google.com/u/1/search-console?resource_id=https%3A%2F%2Ffreshnewnews.com%2F",
      "Value": "",
      "Description": "Open GSC property"
    },
    {
      "Command": "pause",
      "Target": "10000",
      "Value": "",
      "Description": "Wait for GSC to fully load"
    },
    {
      "Command": "forEach",
      "Target": "urlArray",
      "Value": "currentURL",
      "Description": "Loop through all URLs"
    },
    {
      "Command": "echo",
      "Target": "Submitting URL: ${currentURL}",
      "Value": "green",
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"gb\"]/div[2]/div[2]/div[2]/form/div/div/div/div/div/div/input[2]",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"gb\"]/div[2]/div[2]/div[2]/form/div/div/div/div/div/div/input[2]",
        "xpath=//input[@type='text']",
        "xpath=//input[2]",
        "css=#gb > div.gb_Jd.gb_Md.gb_Xd > div.gb_Rd.gb_0d.gb_Ke.gb_Ue.gb_0e > div.gb_Je > form > div > div > div > div > div > div.d1dlne > input.Ax4B8.ZAGvjd"
      ],
      "Description": ""
    },
    {
      "Command": "type",
      "Target": "xpath=//*[@id=\"gb\"]/div[2]/div[2]/div[2]/form/div/div/div/div/div/div/input[2]",
      "Value": "${currentURL}",
      "Targets": [
        "xpath=//*[@id=\"gb\"]/div[2]/div[2]/div[2]/form/div/div/div/div/div/div/input[2]",
        "xpath=//input[@type='text']",
        "xpath=//input[2]",
        "css=#gb > div.gb_Jd.gb_Md.gb_Xd > div.gb_Rd.gb_0d.gb_Ke.gb_Ue.gb_0e > div.gb_Je > form > div > div > div > div > div > div.d1dlne > input.Ax4B8.ZAGvjd"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "css=#gb > div.gb_Jd.gb_Md.gb_Xd > div.gb_Rd.gb_0d.gb_Ke.gb_Ue.gb_0e > div.gb_Je > form > button.gb_Ne > svg",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"gb\"]/div[2]/div[2]/div[2]/form/button[3]/svg",
        "css=#gb > div.gb_Jd.gb_Md.gb_Xd > div.gb_Rd.gb_0d.gb_Ke.gb_Ue.gb_0e > div.gb_Je > form > button.gb_Ne > svg"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"ow13\"]/div[3]/span/div/span/span/div/span/span",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"ow13\"]/div[3]/span/div/span/span/div/span/span",
        "xpath=//span/span/div/span/span",
        "css=#ow13 > div.CerIhf > span > div > span > span > div > span > span.cTsG4"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"yDmH0d\"]/div[6]/div[2]/div/div[2]/div/button/span[5]",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"yDmH0d\"]/div[6]/div[2]/div/div[2]/div/button/span[5]",
        "xpath=//span[5]",
        "css=#yDmH0d > div.uW2Fw-Sx9Kwc.uW2Fw-Sx9Kwc-OWXEXe-n2to0e.uW2Fw-qON5Qe-FoKg4d-Sx9Kwc-fZiSAe.yaahMe.y4Y5Tb.vaOP1b.b0BlYc.uW2Fw-Sx9Kwc-OWXEXe-FNFY6c > div.uW2Fw-wzTsW > div > div.uW2Fw-T0kwCb > div > button > span.mUIrbf-vQzf8d"
      ],
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": "End of loop"
    }
  ]
}

17 February 2025

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.google.com/recaptcha/api.js?render=6LfBtdkqAAAAAMTW5EedKrwh_yuGGNEbp5B-g96i"></script>

<script>


function addRecaptchaTokenToForms() {

    grecaptcha.ready(function () {

        grecaptcha.execute('6LfBtdkqAAAAAMTW5EedKrwh_yuGGNEbp5B-g96i', { action: 'elementor_form' }).then(function (token) {

            document.querySelectorAll('form').forEach(function (form) {

                let recaptchaInput = form.querySelector('input[name="recaptcha_token"]');

                if (!recaptchaInput) {

                    // If the hidden input doesn't exist, create it

                    recaptchaInput = document.createElement('input');

                    recaptchaInput.type = 'hidden';

                    recaptchaInput.name = 'recaptcha_token';

                    form.appendChild(recaptchaInput);

                }

                // Update the token value

                recaptchaInput.value = token;

            });

        });

    });

}


// Update reCAPTCHA token on form submission

function handleFormSubmission() {

    document.querySelectorAll('form').forEach(function (form) {

        form.addEventListener('submit', function (event) {

            event.preventDefault(); // Prevent default submission to ensure token is updated

            grecaptcha.ready(function () {

                grecaptcha.execute('6LfBtdkqAAAAAMTW5EedKrwh_yuGGNEbp5B-g96i', { action: 'elementor_form' }).then(function (token) {

                    let recaptchaInput = form.querySelector('input[name="recaptcha_token"]');

                    if (!recaptchaInput) {

                        recaptchaInput = document.createElement('input');

                        recaptchaInput.type = 'hidden';

                        recaptchaInput.name = 'recaptcha_token';

                        form.appendChild(recaptchaInput);

                    }

                    recaptchaInput.value = token;

                   

                });

            });

        });

    });

}


// Initial call when the page loads

addRecaptchaTokenToForms();

handleFormSubmission();


// Reattach reCAPTCHA token and submission handler when Elementor forms reload via AJAX

document.addEventListener('DOMContentLoaded', function () {

    document.body.addEventListener('DOMNodeInserted', function (event) {

        if (event.target.classList && event.target.classList.contains('elementor-widget-form')) {

            addRecaptchaTokenToForms();

            handleFormSubmission();

        }

    });

});


</script>

<style>

.grecaptcha-badge{

    display: none !important;

}

</style>

<?php

 });



/* add_action('elementor_pro/forms/new_record', function($record, $handler) { */

add_action('elementor_pro/forms/validation', function($record, $handler) {

    

    // Ensure this is the form you want to validate

    $form_name = $record->get_form_settings('form_name');

    /* Uncomment this if you want to target a specific form

    if ('your_form_name' !== $form_name) {

        return;

    }

    */


    $raw_fields = $record->get('fields');

    $fields = [];

    foreach ($raw_fields as $id => $field) {

        $fields[$id] = $field['value'];

    }


    // Get the reCAPTCHA token from the hidden field

    $recaptcha_token = isset($_POST['recaptcha_token']) ? sanitize_text_field($_POST['recaptcha_token']) : '';


    $recaptcha_secret = '6LfBtdkqAAAAAEZhOEScydwXVGauTNUxCWO0b2pi'; // Replace with your reCAPTCHA secret key


    // Verify the reCAPTCHA response

    $response = wp_remote_post('https://www.google.com/recaptcha/api/siteverify', [

        'body' => [

            'secret'   => $recaptcha_secret,

            'response' => $recaptcha_token,

            'remoteip' => $_SERVER['REMOTE_ADDR'], // Optional

        ],

    ]);


    $response_body = wp_remote_retrieve_body($response);

    $result = json_decode($response_body, true);


    if (empty($result['success']) || $result['score'] < 0.5) {

        // Stop the form submission if validation fails

        $handler->add_error_message('reCAPTCHA validation failed. Please try again.');

        $handler->add_error('recaptcha_token', 'Please verify you are not a robot.');


        // Stop further actions (e.g., saving data or sending email)

        $handler->add_response_data('success', false);


        return false; // Exit the hook early

    }


    // If validation passes, continue with normal form processing

}, 10, 2);

29 January 2025

How to create multi step form with validations?

Create multi step form with validations


 <!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Multi-Step Form with Parsley.js Validation</title>

  <!-- Bootstrap CSS -->

  <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">

  <!-- Parsley.js CSS -->

  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/parsleyjs@2.9.2/src/parsley.min.css">

  <style>

  .form-section {

  padding-left: 15px;

  border-left: 2px solid #FF851B;

  display: none;

}

.form-section.current {

  display: inherit;

}

.btn-info, .btn-default {

  margin-top: 10px;

}

html.codepen body {

  margin: 1em;

}


  </style>

</head>

<body>

  <div class="container mt-5">

   

<form class="demo-form">

  <div class="form-section">

    <label for="firstname">First Name:</label>

    <input type="text" class="form-control" name="firstname" required="">


    <label for="lastname">Last Name:</label>

    <input type="text" class="form-control" name="lastname" required="">

  </div>


  <div class="form-section">

    <label for="email">11Email11:</label>

    <input type="email" class="form-control" name="email" required="">

  </div>

  

  <div class="form-section">

    <label for="email">Email:</label>

    <input type="email" class="form-control" name="email" required="">

  </div>


  <div class="form-section">

    <label for="color">Favorite color:</label>

    <input type="text" class="form-control" name="color" required="">

  </div>


  <div class="form-navigation">

    <button type="button" class="previous btn btn-info pull-left">&lt; Previous</button>

    <button type="button" class="next btn btn-info pull-right">Next &gt;</button>

    <input type="submit" class="btn btn-default pull-right">

    <span class="clearfix"></span>

  </div>


</form>


  </div>


  <!-- Bootstrap JS -->

  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>

  <!-- Parsley.js JS -->

  <script src="https://cdn.jsdelivr.net/npm/parsleyjs@2.9.2/dist/parsley.min.js"></script>

  

  <script>

  $(function () {

  var $sections = $('.form-section');


  function navigateTo(index) {

    // Mark the current section with the class 'current'

    $sections

      .removeClass('current')

      .eq(index)

        .addClass('current');

    // Show only the navigation buttons that make sense for the current section:

    $('.form-navigation .previous').toggle(index > 0);

    var atTheEnd = index >= $sections.length - 1;

    $('.form-navigation .next').toggle(!atTheEnd);

    $('.form-navigation [type=submit]').toggle(atTheEnd);

  }


  function curIndex() {

    // Return the current index by looking at which section has the class 'current'

    return $sections.index($sections.filter('.current'));

  }


  // Previous button is easy, just go back

  $('.form-navigation .previous').click(function() {

    navigateTo(curIndex() - 1);

  });


  // Next button goes forward iff current block validates

  $('.form-navigation .next').click(function() {

    if ($('.demo-form').parsley().validate({group: 'block-' + curIndex()}))

      navigateTo(curIndex() + 1);

  });


  // Prepare sections by setting the `data-parsley-group` attribute to 'block-0', 'block-1', etc.

  $sections.each(function(index, section) {

    $(section).find(':input').attr('data-parsley-group', 'block-' + index);

  });

  navigateTo(0); // Start at the beginning

});

  </script>

</body>

</html>


How to add google auto search places and change date picker format in elementor's input?

Add google auto search places and change date picker format in elementor's input

add_action('wp_footer',function(){

    ?>


<script src="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/4.6.13/flatpickr.min.js" integrity="sha512-K/oyQtMXpxI4+K0W7H25UopjM8pzq0yrVdFdG21Fh5dBe91I40pDd9A4lzNlHPHBIP2cwZuoxaUSX0GJSObvGA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAPvILrgZkge5Bhu37t6Vi4kL-iSwx3t-k&libraries=places" defer></script>


<script>

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


        $('input[name="form_fields[field_0b486bd]"], input[name="form_fields[field_ffb1494]"]').each(function() {

            var input = this; 


            if (typeof google !== 'undefined') {


                var autocomplete = new google.maps.places.Autocomplete(input, {

                    componentRestrictions: { country: 'ca' },  

                    types: ['geocode']  

                });


                google.maps.event.addListener(autocomplete, 'place_changed', function() {

                    var place = autocomplete.getPlace();

                    if (place.geometry) {


                        console.log("Selected place: ", place);

                    } else {

                        console.log("Place not found");

                    }

                });

            }

        });


    });


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


    setTimeout(function() {

        flatpickr(".flatpickr-input", {

            minDate: "today",  

            dateFormat: "Y-m-d", 

        });

    }, 1000); 

});


</script>


<?php

});

How to create section Showcase/Scale animation in viewport with Scrollmagic?

Section Showcase/Scale animation in viewport with Scrollmagic 


add_action("wp_head", function () {

    ?>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.1/gsap.min.js"></script> <!-- GSAP -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js"></script> <!-- ScrollMagic GSAP Plugin -->

    <script>


document.addEventListener("DOMContentLoaded", function() {


var controller = new ScrollMagic.Controller();


var targetElement = document.querySelector("#animate2");

var bodyElement = document.querySelector("body");

var triggerElement1 = document.querySelector("#trigger3"); 

var triggerElement2 = document.querySelector("#trigger4"); 


if (targetElement && triggerElement1 && triggerElement2) {


    var screenWidth = screen.width;

    var screenHeight = screen.height;


    console.log("Screen resolution: " + screenWidth + "x" + screenHeight);


   var scene2 = new ScrollMagic.Scene({

      triggerElement: "#trigger3",   

      triggerHook: 0.5,                

      duration: screenHeight,                 

    })

    .on("progress", function(e) {


      var progressHeight = e.progress * screenHeight; 

      targetElement.style.height = progressHeight + "px"; 

    })

    .setTween(

      gsap.to(targetElement, {

        backgroundColor: "green", 

        ease: "power1.out", 

      })

    )


    .addTo(controller); 


    var animationPlaying = false;


    triggerElement2.addEventListener("click", function() {

        if (animationPlaying) {


            scene.reverse();

            resetAnimation(targetElement); 

            animationPlaying = false; 

        }

    });


    scene.on("start", function() {

        animationPlaying = true; 

    });


    scene.on("end", function() {

        animationPlaying = false; 

        resetAnimation(targetElement); 

    });


} else {

    console.error("Elements #animate1, #trigger1 or #trigger2 not found!");

}


function resetAnimation(element) {

    element.style.backgroundColor = ""; 

    element.style.transform = ""; 

}

});

    </script>

    <?php

});

?>


/*---------------------CSS---------------------------*/

.home {

    position: relative;

 }

 body::after {

     background: #fff5f9c9;

     width: 100%;

     height: 100%;

     content: "";

     position: fixed;

     top: 0;

     bottom: 0;

     left: 0;

     right: 0;

     z-index: 9999;

     transition: 0.5s all;

     opacity: 0;

     pointer-events: none;

 }

 .activeOverlay::after{

     opacity: 1;

     pointer-events: unset;

 }

 #animate1{

     transition: 0.5s all;

     z-index: 999999; 

 }

 .activeScaleAnimation {

     transition: 0.5s all;

     transform: scale(1.2);

 }

 

How to create bubble scale animation with Scrollmagic?

 Create bubble scale animation with Scrollmagic

add_action("wp_head", function () {

    ?>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js"></script>

    <script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js"></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.1/gsap.min.js"></script> <!-- GSAP -->

    <script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/animation.gsap.min.js"></script> <!-- ScrollMagic GSAP Plugin -->

    <script>


document.addEventListener("DOMContentLoaded", function() {

    var controller = new ScrollMagic.Controller();

    var scene = new ScrollMagic.Scene({

triggerElement: "#bubbleTrigger1"

})

                        .setClassToggle(".bubbleAnimate", "activebubble") 

                        .addTo(controller);


});

</script>

<?php

});

?>


/*---------------------CSS---------------------------*/

.bubbleAnimate {

    position: relative;

    overflow: hidden !important;

}

.bubbleAnimate::after {

    width: 30px;

    height: 30px;

    z-index: -2;

    content: "";

    background: #FFF5F9;

    position: absolute;

    top: -15px;

    left: 0;

    right: 0;

    border-radius: 200%;

    margin: auto;

    transition: 0.9s all;

}

.activebubble::after{

    transform: scale(100);

}

How to create youtube videos slider with play and pause option in wordpress?

Create youtube videos slider with play and pause option in wordpress youtube videos slider Use this shortcode:- [punjab_today] function my_...