Skip to main content

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...

You tube iframe video play one by one conterminously

<?php
/**
 * Template Name: Video Page
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages and that
 * other "pages" on your WordPress site will use a different template.
 *
 * @package WordPress
 * @subpackage Twenty_Fifteen
 * @since Twenty Fifteen 1.0
 */
get_header();
     global $wpdb;
 ?>

<!-- This loads the YouTube IFrame Player API code You tube iframe video play one by one conterminously  -->
<script src="http://www.youtube.com/player_api"></script>
<script src="<?php echo esc_url( get_template_directory_uri() ); ?>/js/jquery.fancybox.js"></script>   
<script src="<?php echo esc_url( get_template_directory_uri() ); ?>/js/jquery.cookie.js"></script>   

<link rel='stylesheet'  href='<?php echo esc_url( get_template_directory_uri() ); ?>/js/jquery.fancybox.css' type='text/css' media='all' />

<script>
function onPlayerReady(event) {
    event.target.playVideo();
}
function onPlayerStateChange(event) {
 if (event.data === 0) {
 var id=jQuery.cookie("vvid");
var arr = id.split('_');
       var testid=  Number(arr[1])+1;
     $('.videowrap iframe').each(function(){
   var testids=$(this).attr('id');
   $(this).replaceWith('<div id="'+ testids +'" class="videotest" style="display: none;"> </div>')
  });
    $( ".auto_" +testid ).trigger( "click" );
    }
}
$(document).ready(function(){
$(".extra_link").hide();
$(".videotest").hide();
$(".video-1").on("click", function(event) {
  event.preventDefault();
   var vid=$(event.currentTarget).attr("id");
  var id=$(event.currentTarget).attr("data-id");
  var dataurl=$(event.currentTarget).attr("data-url");
  $(".videoouter iframe").prop("src", $(event.currentTarget).attr("href"));
  $(".extra_link").hide();
  $("#video" +id).show();
});


$(".video-2").on("click", function(event) {
 $('.videowrap iframe').each(function(){
   var testids=$(this).attr('id');
   $(this).replaceWith('<div id="'+ testids +'" class="videotest" style="display: none;"> </div>')
  });

  $(".videotest").hide();
  event.preventDefault();
    var vvid=$(event.currentTarget).attr("vvid");
   var vid=$(event.currentTarget).attr("id");
  var id=$(event.currentTarget).attr("data-id");
  var dataurl=$(event.currentTarget).attr("data-url");
  $("#notloop").hide();
  $(".extra_link").hide();
   $("#video" +id).show();
   $("#videotest" +vvid).show();
   jQuery.cookie("vvid", vvid); // Sample 1
     player0 = new YT.Player('videotest'+vvid, {
        height: '450',
        width: '740',
        videoId: dataurl,
        events: {
            'onReady': onPlayerReady,
            'onStateChange': onPlayerStateChange
        }
    });

});
});
</script>
<script>
    function searchFriends(){
   var keyword=$(".friendsearch").val();
     console.log(keyword);
   keyword = keyword.replace(/\s/g, '');
    console.log(keyword);
    if(keyword == ''){
        $('.allvideo').show();
    }else{
        $('.allvideo').each(function(){
                         var fname = $(this).attr('fname');
                         var nfname=fname.toLowerCase();
                         var n=nfname.indexOf(""+keyword+"");
                         if(n >=0){          
                         $(this).show();                                                                                          
                            }else{                                                                                      
                         $(this).hide();
                         //$("#div1").html("No Result Found......");
                         }
                         });                                                                     
    }
}  
</script>
<style>
.pdffile{
 display:block;
}
</style>
<div id="primary" class="content-area">
  <main id="main" class="site-main" role="main">
   <div class="container video_section">
             <header class="entry-header">
                    <h1 class="entry-title"><?php the_title(); ?></h1>
                </header>

                <div class="videoouter" >
               
                <div class="videowrap">
  
                 <iframe id="notloop" style="width:65%; height:450px; margin:0 auto;" src="http://www.youtube.com/embed/QPLuoyPF44U" frameborder="0" allowfullscreen></iframe>
     <?php
                        $sql="select * from video_category order by `sort_order` asc";
                        $video_categorys = $wpdb->get_results($sql);
                        foreach ($video_categorys as $video_category) {
        $category_id = $video_category->id;
                            $sql1="select * from video_link where video_category_id='$category_id' order by `video_order` asc";
                            $video_links = $wpdb->get_results($sql1);
     
                          
                            foreach ($video_links as $video_link) {
        $ttt++;
        $id=$video_link->id;
                                $video_title1 = $video_link->video_title1;
                                 $video_url1 = $video_link->video_url1;
         $id = $video_link->id;
          $vvid=$video_link->auto;
         preg_match("/[^\/]+$/", "$video_url1", $matches);
        $last_word = $matches[0];
        if(is_user_logged_in() && $video_link->auto!="")
         {
        ?>
       
        <div id="videotest<?php echo $vvid; ?>" class="videotest">
        </div>
       
        <?php
         }
       }
      }
      
                            ?>
     <?php
                        $sql="select * from video_category order by `sort_order` asc";
                        $video_categorys = $wpdb->get_results($sql);
                        foreach ($video_categorys as $video_category) {
        $category_id = $video_category->id;
                            $sql1="select * from video_link where video_category_id='$category_id' order by `video_order` asc";
                            $video_links = $wpdb->get_results($sql1);
     
                          
                            foreach ($video_links as $video_link) {
        $ttt++;
        $id=$video_link->id;
                                $video_title1 = $video_link->video_title1;
                                 $video_url1 = $video_link->video_url1;
         $id = $video_link->id;
          $vvid=$video_link->auto;
         preg_match("/[^\/]+$/", "$video_url1", $matches);
        $last_word = $matches[0];
    
        if($video_url1!=""){
                            ?>
     
     <div class="extra_link" id="video<?php echo $id ?>">
      <?php   echo "<a data-id='$id' data-url='$last_word' href='http://www.youtube.com/embed/".$last_word."?rel=0&autoplay=1' onClick='showdata1($id)' class='testlink video-1 active' title='' ><div class='extra_link'></div></a>"; ?>
     </div>
      <?php } }} ?>
                </div>
               
                <div class="clear"></div>
                </div>
  
               
                <div class="video_tab_outer">
                 <div class="left">
                     <div class="video_search_box"><input type="text" value="" class="friendsearch" onkeyup="searchFriends(this)"  title="Search this course " placeholder="Search video" /><input type="button" value="Search" title="Search" /></div>
                     <h3 class="expand_collapse_tab"><a href="javascript:;" class="expandall">Expand all</a> <span>|</span> <a href="javascript:;" class="collapesall">Collapse all</a></h3>
       <?php
                                while ( have_posts() ) : the_post();
                                    the_content();
                                endwhile;
                                ?>
                                <?php
                          
                        $sql="select * from video_category order by `sort_order` asc";
                        $video_categorys = $wpdb->get_results($sql);
                        foreach ($video_categorys as $video_category) {
                            ?>
                           
                            <h2><?php  echo $category_name = $video_category->category_name; ?></h2>
                           
                            <?php
                            //echo $category_name = $video_category->category_name;
                            $category_id = $video_category->id;
                            $sql1="select * from video_link where video_category_id='$category_id' order by `video_order` asc";
                            $video_links = $wpdb->get_results($sql1);
     
                            echo "<ul class='video_list'>";
                            foreach ($video_links as $video_link) {
        $count++;
        $id=$video_link->id;
                                $video_title = $video_link->video_title;
                                 $video_url = $video_link->video_url;
         $id = $video_link->id;
         $vvid=$video_link->auto;
       preg_match("/[^\/]+$/", "$video_url", $matches);
        $last_word = $matches[0];
                                $video_length = $video_link->video_length;
        $a=str_replace(' ','',$video_title);
                                if ( is_user_logged_in() && $video_link->auto =="") {
                                    echo "<li class='allvideo'  fname=\"$a\"><a data-url='$last_word' href='http://www.youtube.com/embed/$last_word?rel=0&autoplay=1' id='$last_word' class=' video-1 active' data-id='$id' title='' onClick='showdata($id)'>";
                                    echo "<span>".$video_title."</span><samp>".$video_length."</samp>";
                                    echo "</a></li>";
                                    //echo "<br>";
        }
         else if(is_user_logged_in() && $video_link->auto!="")
         {
          echo "<li class='allvideo'  fname=\"$a\"><a data-url='$last_word' vvid='$vvid' href='http://www.youtube.com/embed/$last_word?rel=0&autoplay=1' id='$last_word' class='$vvid  video-2 active' data-id='$id' title='' onClick='showdata($id)'>";
                                    echo "<span>".$video_title."</span><samp>".$video_length."</samp>";
                                    echo "</a></li>";
         }
                             else {
                                if($video_link->level=="Registered")
                                {
                                          echo "<li class='allvideo' fname=\"$a\"><a href='javascript:;'>";
                                    echo "<span>".$video_title."</span><samp>".$video_length."</samp>";
                                    //echo "...LOck";
                                    echo "</a></li>";
                                }else
                                {
                                           echo "<li class='allvideo'  fname=\"$a\"><a  data-url='$last_word'  href='http://www.youtube.com/embed/".$last_word."?rel=0&autoplay=1' onClick='showdata($id)' class='video-1 love$count active' title='' >";
                                    echo "<span>".$video_title."</span><samp>".$video_length."</samp>";
                                    //echo "<br>";
                                    echo "</a></li>";
                                }      
                            }
                            }
                       
                       
                        if(empty($video_links))
                        {
                            echo "<li><span>No Video available...</span></li>";
                        }
                        echo "</ul>";
                        }
                                ?>
                    </div>
                    <div class="right">
                     <div class="tabs">
    <ul class="tab-links">
        <li class="active"><a href="#tab1">Course details</a></li>
        <li  > <a  class="transcrlpt" href="#tab2">Transcript</a></li>
     <li  > <a  class="pdf" href="#tab3">PDF</a></li>
    </ul>

    <div class="tab-content">
        <div id="tab1" class="tab active">
            <h1>Course details</h1>
          
<p><br />
&nbsp;</p>
        </div>

        <div id="tab2" class="tab ">
               <h1>Transcript</h1>
               <div id="transcrlpt">

      </div>
              
        </div>



       <div id="tab3" class="tab">
    <div id="pdfdata">
   
    <?php
       
                        $sql="select * from video_category order by `sort_order` asc";
                        $tests= $wpdb->get_results($sql);
                        foreach ($tests as $test) {
      $files = explode(",",$test->pdf_file);
  $url=get_site_url();
  $id=$test->id;
  echo "<div id='cat$id' class='pdffile'>";
foreach($files as $file)
{
 if($file!="")
 {


 $c++;
 //echo "<a target='_blank' href='$url/wp-content/themes/superiorkneerehab/uploads/$file'>$file</a>";
 ?>
 <a href="<?php echo $url; ?>/wp-content/themes/superiorkneerehab/download.php?download_file=<?php echo $file; ?>">Download&nbsp; <?php echo $file; ?></a>
 <?php
 echo "<br>";
 }

}
echo "</div>";
      }
    ?>
   
   
   
    </div>
           
      
        </div>










    </div>
</div>
                   
                    </div>
                </div>
  

            </div>
  </main><!-- .site-main -->
 </div><!-- .content-area -->
   
<script>
 jQuery(document).ready(function(){
  jQuery(".expandall").click(function(){
   jQuery(".video_list").slideDown();
  });
  jQuery(".collapesall").click(function(){
   jQuery(".video_list").slideUp();
  });

  jQuery('.video_tab_outer h2').click(function(){
   jQuery(this).next(".video_list").slideToggle();
  });

  jQuery('.tabs .tab-links a').on('click', function(e)  {
        var currentAttrValue = jQuery(this).attr('href');
        // Show/Hide Tabs
        jQuery('.tabs ' + currentAttrValue).show().siblings().hide();

        // Change/remove current tab to active
        jQuery(this).parent('li').addClass('active').siblings().removeClass('active');

        e.preventDefault();
    });
jQuery('.video_list a').on('click', function(e)  {
        var currentAttrValue = "#tab2";


        // Show/Hide Tabs
        jQuery('.tabs ' + currentAttrValue).show().siblings().hide();

        // Change/remove current tab to active
        jQuery(".transcrlpt").parent('li').addClass('active').siblings().removeClass('active');

      //  e.preventDefault();
  




    });


    });
 function showdata(x)
 {
       jQuery.ajax({
          type:'POST',
          data:{action:'get_transcrlpt',id:x},
          url: '<?php echo  get_site_url(); ?>/wp-content/themes/superiorkneerehab/action.php',
          success: function(value) {  
     // location.reload();
           jQuery("#transcrlpt").html(value);
          },
        });
          jQuery.ajax({
          type:'POST',
          data:{action:'get_pdf',id:x},
          url: '<?php echo  get_site_url(); ?>/wp-content/themes/superiorkneerehab/action.php',
          success: function(value) {  
     // location.reload();
          // jQuery("#pdfdata").html(value);
    jQuery("#cat" +value).show();
          },
        });
 }
 function showdata1(x)
 {
       jQuery.ajax({
          type:'POST',
          data:{action:'get_transcrlpt1',id:x},
          url: '<?php echo  get_site_url(); ?>/wp-content/themes/superiorkneerehab/action.php',
          success: function(value) {  
     // location.reload();
           jQuery("#transcrlpt").html(value);
          },
        });
          jQuery.ajax({
          type:'POST',
          data:{action:'get_pdf',id:x},
          url: '<?php echo  get_site_url(); ?>/wp-content/themes/superiorkneerehab/action.php',
          success: function(value) {  
     // location.reload();
           //jQuery("#pdfdata").html(value);
      jQuery("#cat" +value).show();
          },
        });
 }
</script>
<?php get_footer(); ?>

Comments

Popular posts from this blog

Create Signature pad with save on database in php

Create Signature pad with save on database in php 1.create a folder images index.php ============   <!DOCTYPE >     <head>     <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />     <title>Signature Pad</title>     <script type="text/javascript" src="jquery-1.8.0.min.js"></script>     <script type="text/javascript"> $(document).ready(function () {     /** Set Canvas Size **/     var canvasWidth = 400;     var canvasHeight = 100;     /** IE SUPPORT **/     var canvasDiv = document.getElementById('signaturePad');     canvas = document.createElement('canvas');     canvas.setAttribute('width', canvasWidth);     canvas.setAttribute('height', canvasHeight);     canvas.setAttribute('id', 'canvas');     canvasDiv.appendChild(canvas);    ...

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url, ...

WooCommerce Mini cart With Ajax

WooCommerce Mini cart //MINI CART SECTION   <div class="productdiv rightcart">                                                         <?php if ( ! WC()->cart->is_empty() ) : ?>     <ul class="woocommerce-mini-cart cart_list product_list_widget <?php echo esc_attr( $args['list_class'] ); ?>">         <?php             do_action( 'woocommerce_before_mini_cart_contents' );             foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {                 $_product     = apply_filters( 'woocommerce_cart_item_pro...