Skip to content

Instantly share code, notes, and snippets.

View kirandash's full-sized avatar

Kiran kirandash

  • Singapore
  • 14:42 (UTC +08:00)
View GitHub Profile
@kirandash
kirandash / functions.php
Created April 19, 2017 05:44
Register Custom Post type
<?php
/*
Plugin Name: Demo
Plugin URI: demo.com
Description: Demo Features
Version: 1.0.0
Author: WordPress.org
Author URI: demo.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@kirandash
kirandash / main.js
Created April 17, 2017 10:13
Expandable Buttons
/********************************
* Expandible Buttons *
********************************/
focusActiveCheck();
var focusBtn = $("#page-focus .focus-image");
focusBtn.click(function(){
var target = $(this).attr('data-expand');
$('#expandables').find(".expand-content").hide();
$('#expandables').find(".expand-content[data-expandtarget='"+ target +"']").show();
if(target == "our-history" || target == "volunteers" || target == "support-us"){
@kirandash
kirandash / banner.php
Last active April 17, 2017 09:18
Random banner image
<?php
// Theme_mod settings to check.
$settings = get_theme_mod( 'ctrctheme_banner_inner_images' );
$fullImgArray = array();
foreach( $settings as $setting ) :
$fullimgsrc = wp_get_attachment_image_src( $setting['ctrctheme_banner_inner_image'], 'full' );
$smimgsrc = wp_get_attachment_image_src( $setting['ctrctheme_banner_inner_image_xs'], 'full' );
@kirandash
kirandash / jquery.countdown.js
Created April 15, 2017 08:42
countdown is a simple jquery plugin for countdowns
// Generated by CoffeeScript 1.4.0
/*
countdown is a simple jquery plugin for countdowns
Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
and GPL-3.0 (http://opensource.org/licenses/GPL-3.0) licenses.
@source: http://github.com/rendro/countdown/
@autor: Robert Fleischmann
@kirandash
kirandash / banner.php
Last active April 21, 2017 09:10
Owl carousel animation with random start point
<?php if(have_rows('home_banner_images')): $totalSlides = count( get_field('home_banner_images') ) - 1; ?>
<div id="slider">
<div id="home-slider" class="owl-carousel owl-theme" data-slides="<?php echo $totalSlides; ?>">
<?php
$slideCount = 1;
while(have_rows('home_banner_images')): the_row();
$banner_image = get_sub_field('home_banner_image');
$banner_image_mob = get_sub_field('home_banner_image_mobile');
$banner_title = get_sub_field('home_banner_slide_title');
$banner_caption = get_sub_field('home_banner_slide_caption');
@kirandash
kirandash / main.js
Created April 14, 2017 10:53
Full screen Banner with fixed header
/********************************
* Banner Home *
********************************/
function bannerResize() {
var width = $(window).width();
var height = $(window).height();
var headerHeight = $('header#masthead').outerHeight();
$('#banner-home .banner-item').width(width);
$('#banner-home .banner-item').height(height - headerHeight);
@kirandash
kirandash / main.js
Created April 12, 2017 10:24
Gravity form post AJAX submission jquery call
jQuery(document).bind('gform_post_render', function(){
// code to trigger on AJAX form render
$('select').fancySelect();
formResize();
$(window).on('resize', formResize);
$(window).on('load',formResize);
$('select').on('change', formResize);
$('.fancy-select .options li').on('click', formResize);
@kirandash
kirandash / content.php
Created April 7, 2017 08:12
WPML get translated content of a string from all languages if available
<?php
global $sitepress;
// save current language
$current_lang = $sitepress->get_current_language();
//set your language
$my_lang = 'es';
//switch to defined language
$sitepress->switch_lang($my_lang);
@kirandash
kirandash / main.js
Last active April 6, 2017 11:01
Custom validation error position - Gravity form
<script>
var errorHtml = jQuery('.validation_error').html();
if(jQuery('#contact-form .gform_wrapper').hasClass('gform_validation_error')){
jQuery('#contact-form .validation_error').remove();
jQuery('#contact-form .gform_footer').append('<div class="validation_error"><span>'+errorHtml+'</span></div>');
}else {
jQuery('.validation_error').css('display', 'none');
}
</script>
@kirandash
kirandash / index.html
Last active March 20, 2017 06:40
Hamburger Icon
<style>
/* Hamburger icon */
.c-hamburger {
position: relative;
overflow: hidden;
margin: 0;
padding: 0;
width: 34px;
height: 34px;
font-size: 0;