Skip to main content

Posts

Showing posts from February, 2016

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,

WordPress Resize Thumbnail Image

<?php //WordPress Resize Thumbnail Image //aq_resizer.php /**  * Title         : Aqua Resizer  * Description   : Resizes WordPress images on the fly  * Version       : 1.1.7  * Author        : Syamil MJ  * Author URI    : http://aquagraphite.com  * License       : WTFPL - http://sam.zoy.org/wtfpl/  * Documentation : https://github.com/sy4mil/Aqua-Resizer/  *  * @param string  $url    - (required) must be uploaded using wp media uploader  * @param int     $width  - (required)  * @param int     $height - (optional)  * @param bool    $crop   - (optional) default to soft crop  * @param bool    $single - (optional) returns an array if false  * @uses  wp_upload_dir()  * @uses  image_resize_dimensions() | image_resize()  * @uses  wp_get_image_editor()  *  * @return str|array  // Set size for image $image_size = array( 'width'  => 600, 'height' => 380 ); // Get img URL, resize & crop $thumb   = get_post_thumbnail_id(); $im

Video Play in background image

Video Play in background image <style> body {   margin: 0;   background: #000; } video {     position: fixed;     top: 50%;     left: 50%;     min-width: 100%;     min-height: 100%;     width: auto;     height: auto;     z-index: -100;     transform: translateX(-50%) translateY(-50%);  background: url('//demosthenes.info/assets/images/polina.jpg') no-repeat;   background-size: cover;   transition: 1s opacity; } .stopfade {    opacity: .5; } #polina {   font-family: Agenda-Light, Agenda Light, Agenda, Arial Narrow, sans-serif;   font-weight:100;   background: rgba(0,0,0,0.3);   color: white;   padding: 2rem;   width: 33%;   margin:2rem;   float: right;   font-size: 1.2rem; } h1 {   font-size: 3rem;   text-transform: uppercase;   margin-top: 0;   letter-spacing: .3rem; } #polina button {   display: block;   width: 80%;   padding: .4rem;   border: none;   margin: 1rem auto;   font-size: 1.3rem;   background: rgba(255,255,255

PHP Captcha Code

Cuustom Captcha //captcha.php <?php session_start(); $ranStr = md5(microtime()); $ranStr = substr($ranStr, 0, 6); $_SESSION['cap_code'] = $ranStr; $newImage = imagecreatefromjpeg("cap_bg.jpg"); $txtColor = imagecolorallocate($newImage, 0, 545, 1); imagestring($newImage, 15, 5, 5, $ranStr, $txtColor); header("Content-type: image/jpeg"); imagejpeg($newImage); ?> <?php session_start(); $cap = 'notEq'; if ($_SERVER['REQUEST_METHOD'] == 'POST') {     if ($_POST['captcha'] == $_SESSION['cap_code']) {         // Captcha verification is Correct. Do something here!         $cap = 'Eq';     } else {         // Captcha verification is wrong. Take other action         $cap = '';     } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>     <head>         <meta http-equiv="Content-Type" content="

API

<?php //WP Search  in API define ('DB_USER', 'root'); define ('DB_PASSWORD', ''); define ('DB_HOST', 'localhost'); define ('DB_NAME', 'cabcouk_db1'); $con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME); if (!$con) {     die("Connection failed: " . mysqli_connect_error()); } $terms = $_REQUEST[ 's' ]; $exploded = explode( ' ', $terms ); if( $exploded === FALSE || count( $exploded ) == 0 ) $exploded = array( 0 => $terms ); $where = '';              foreach( $exploded as $tag ) :             $where .= "             AND (             (wp_posts.post_title LIKE '%$tag%')             OR (wp_posts.post_content LIKE '%$tag%')             OR EXISTS (             SELECT * FROM wp_postmeta             WHERE post_id = wp_posts.ID             AND (";             $where .= " (meta_value RLIKE '[[:<:]]".$tag."