Skip to content

Instantly share code, notes, and snippets.

View kirandash's full-sized avatar

Kiran kirandash

View GitHub Profile
@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
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 / 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 / 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 / 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 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 / 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 / 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 / functions.php
Created April 19, 2017 06:52
Remove “Category:”, “Tag:”, “Author:” from the_archive_title
<?php
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>' ;
}
return $title;
@kirandash
kirandash / archive.php
Created April 19, 2017 07:42
WP_Query pagination
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$resultsArgs = array(
'post_type' => 'results',
'posts_per_page' => 6,
'paged' => $paged
);
$resultsQuery = new WP_Query($resultsArgs);
if ( $resultsQuery->have_posts() ) :
?>