Skip to content

Instantly share code, notes, and snippets.

@sarat246
sarat246 / gist:de8ca632a69aa65f829dba914cac5555
Created April 29, 2018 19:11 — forked from jchristopher/gist:9d1d2df6d92d084884ee
Customize the parent element for SearchWP Live Ajax Search results
<?php
function my_searchwp_live_search_configs( $configs ) {
// override some defaults
$configs['default'] = array(
'engine' => 'default', // search engine to use (if SearchWP is available)
'parent_el' => '#results-loop', // have the results show up in a custom element
'input' => array(
'delay' => 500, // wait 500ms before triggering a search
'min_chars' => 3, // wait for at least 3 characters before triggering a search
@sarat246
sarat246 / gist:280d60a037414a37415711bff8caad7b
Created April 29, 2018 19:10 — forked from jchristopher/gist:9d1d2df6d92d084884ee
Customize the parent element for SearchWP Live Ajax Search results
<?php
function my_searchwp_live_search_configs( $configs ) {
// override some defaults
$configs['default'] = array(
'engine' => 'default', // search engine to use (if SearchWP is available)
'parent_el' => '#results-loop', // have the results show up in a custom element
'input' => array(
'delay' => 500, // wait 500ms before triggering a search
'min_chars' => 3, // wait for at least 3 characters before triggering a search
@sarat246
sarat246 / SCSS.md
Created January 26, 2018 00:01 — forked from jareware/SCSS.md
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@sarat246
sarat246 / 01-gulpfile.js
Created January 27, 2017 20:02 — forked from markgoodyear/01-gulpfile.js
Comparison between gulp and Grunt. See http://markgoodyear.com/2014/01/getting-started-with-gulp/ for a write-up.
/*!
* gulp
* $ npm install gulp-ruby-sass gulp-autoprefixer gulp-cssnano gulp-jshint gulp-concat gulp-uglify gulp-imagemin gulp-notify gulp-rename gulp-livereload gulp-cache del --save-dev
*/
// Load plugins
var gulp = require('gulp'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
cssnano = require('gulp-cssnano'),
@sarat246
sarat246 / gist:d552f7c78d4f7f62d143e9ec2d872d43
Created September 15, 2016 19:50 — forked from philcook/gist:15bd50aeb8f80315d2bcaa9720c45bbb
For creating conditional based logic for page or any children pages that are under a parent page.
function if_page_or_ancestor_page_is($page_slug = NULL)
{
$is_page = false;
if (is_page()) {
global $post;
/* Get an array of Ancestors and Parents if they exist */
$parents = get_post_ancestors($post->ID);
$all_pages = array_reverse(array_merge($parents, array($post->ID)));
@sarat246
sarat246 / README.md
Last active August 29, 2015 14:12 — forked from jmacqueen/README.md

A basic Grunt configuration for working with the Bones Wordpress Starter theme. To be expanded! Compiles and compresses Sass and uses rsync to update the local installation of Wordpress for testing so I can keep my MAMP installation free of extraneous files...and simply FTP over the final result if it checks out without putting uneccessary node_modules or .scss files on the server by mistake. This was pretty much put together because I kept mistakenly FTPing over my .sass-cache files like an idiot.

For this to work, the theme in development lives in 'src' inside the project directory so node_modules, .sass-cache, gruntfile.js, package.json and src are all together in the top-level directory.

project folder
  .sass-cache
  gruntfile.js
  node_modules
 package.json
window.onload = function() {
function addIcon(el, entity) {
var html = el.innerHTML;
el.innerHTML = '<span style="font-family: \'fontName\'">' + entity + '</span>' + html;
}
var icons = {
'icon-newspaper' : '&#xe000;',
'icon-play' : '&#xe001;',
'icon-film' : '&#xe002;'
},

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter