Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Kuldeep Daftary kuldeepdaftary

🎯
Focusing
  • London
Block or report user

Report or block kuldeepdaftary

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kuldeepdaftary
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: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// 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">
<style>
body {
font: 10px sans-serif;
margin: 0;
}
path.line {
@kuldeepdaftary
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
<?php
// 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
kuldeepdaftary / gist:5803978
Last active Dec 18, 2015
Remove P tags around images in wordpress
View gist:5803978
<?php
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
kuldeepdaftary / gist:5803971
Last active Dec 18, 2015
Decide when you want to apply the auto paragraph Wordpress
View gist:5803971
<?php
add_filter('the_content','my_custom_formatting');
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
else
return wpautop($content);
}
?>
You can’t perform that action at this time.