Skip to content

Instantly share code, notes, and snippets.

@robhadfield
robhadfield / has_class.js
Created April 15, 2016 12:32 — forked from jjmu15/has_class.js
has class function - vanilla JS. Check if element has specified class
// hasClass, takes two params: element and classname
function hasClass(el, cls) {
return el.className && new RegExp("(\\s|^)" + cls + "(\\s|$)").test(el.className);
}
/* use like below */
// Check if an element has class "foo"
if (hasClass(element, "foo")) {

The reason you might not be able to remove the Open Sans font that Wordpress >= 3.8 adds to the frontend is that quite a few WP styles and scripts list 'open-sans' as a dependancy when being registered and enqueued. When you remove the 'open-sans' style the other plugins dependant on it will not load. So you just need to deregister WP's open sans style and register your own, with a false value for the src like below.

Credit to seventhsteel from http://wordpress.org/support/topic/turning-off-open-sans-for-the-38-dashboard

Gradient Animation Trick

CSS gradient colors can't be animated. This demo shows a workaround. Hover to see it in action. Implementation on left, visual explanation on right.

Blog post: Gradient Animation Trick

A Pen by Will Boyd on CodePen.

License.

@robhadfield
robhadfield / wp_insert_post_front_end_form.php
Created August 23, 2012 07:48 — forked from clarklab/wp_insert_post_front_end_form.php
This is a sample front-end form using wp_insert_post(). It's quickly stripped out of my production code from Android and Me, and hasn't been tested alone, so please take it with a grain of salt.
<?
if( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['insert_post'] )) { //check that our form was submitted
$title = $_POST['thread_title']; //set our title
if ($_POST['thread_description']=="") { // check if a description was entered
$description = "See thread title..."; // if not, use placeholder
} else {
$description = $_POST['thread_description']; //if so, use it
@robhadfield
robhadfield / gist:2163306
Created March 22, 2012 20:18 — forked from barbietunnie/gist:2163080
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(