Skip to content

Instantly share code, notes, and snippets.


Kuldeep Daftary kuldeepdaftary

  • London
View GitHub Profile
kuldeepdaftary / es7-async-await.js
Created May 21, 2017 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
View es7-async-await.js
// Async/Await requirements: Latest Chrome/FF browser or Babel:
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill:
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
body {
font: 10px sans-serif;
margin: 0;
path.line {
kuldeepdaftary / gist:5804047
Created Jun 18, 2013
Wordpress intelligent Excerpt. Following function will create an excerpt from content where first sentence ends (with period) or if first sentence is too long it will only show number of characters defined in the function. in following case it'll show 200 characters.
View gist:5804047
// Variable & intelligent excerpt length.
function print_excerpt($length) { // Max excerpt length. Length is set in characters
global $post;
$text = $post->post_excerpt;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
kuldeepdaftary / gist:5803978
Last active Dec 18, 2015
Remove P tags around images in wordpress
View gist:5803978
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
add_filter('the_content', 'filter_ptags_on_images');
kuldeepdaftary / gist:5803971
Last active Dec 18, 2015
Decide when you want to apply the auto paragraph Wordpress
View gist:5803971
function my_custom_formatting($content){
if((get_post_type()=='trend-story') || (get_post_type()=='fashion-story') || (get_post_type()=='how-to-wear-it'))
return $content; //no autop
return wpautop($content);
You can’t perform that action at this time.