Skip to content

Instantly share code, notes, and snippets.

View EnragedSuccubus's full-sized avatar

Nicole EnragedSuccubus

View GitHub Profile
@EnragedSuccubus
EnragedSuccubus / functions.php
Created June 9, 2014 23:02
Add an image to your WordPress RSS feed
// Add to functions.php and namespace your methods! :)
function cg_rss_post_thumbnail( $content ) {
global $post;
if ( has_post_thumbnail( absint( $post->ID ) ) ) {
$content = '<p>' . get_the_post_thumbnail( asbint( $post->ID ) ) . '</p>' . get_the_content();
}
return $content;
}
@EnragedSuccubus
EnragedSuccubus / gist:868e1bda385a9ca4fa0e
Created June 13, 2014 23:49
Standard text domain setup
class My_Awesome_Plugin {
public function __construct() {
add_action( 'init', array( $this, 'setup_textdomain' ) );
}
public static function setup_textdomain() {
$locale = apply_filters( 'plugin_locale', get_locale(), $this->domain );
load_textdomain( $this->domain, WP_LANG_DIR . '/plugin-name/plugin-name-' . $locale . '.mo' );
load_plugin_textdomain( $this->domain, false, $this->plugin_dir . '/languages/' );
}
}
@EnragedSuccubus
EnragedSuccubus / validate_int.php
Last active August 29, 2015 14:04
Validate a string of numbers, even if they are in a list separated by commas
$list_of_ids = '1,2,3,4,5,6';
if ( cg_validate_int( $list_of_ids ) ) {
echo 'Huzzah! We have valide integers!';
}
/**
* Allows us to pass either an array of or a single intger and validate that they are integers
*
* @param int|string $list_of_ids Pass either a single integer or a comma separated list
*
@EnragedSuccubus
EnragedSuccubus / jquery.flexslider.min.js
Created October 16, 2014 17:13
FlexSlider v2.2.2 custom minified fixing last post showing first
/*
* jQuery FlexSlider v2.2.2
* Copyright 2012 WooThemes
* Contributing Author: Tyler Smith
*/
(function(e){e.flexslider=function(t,n){var r=e(t);r.vars=e.extend({},e.flexslider.defaults,n);var i=r.vars.namespace,s=window.navigator&&window.navigator.msPointerEnabled&&window.MSGesture,o=("ontouchstart"in window||s||window.DocumentTouch&&document instanceof DocumentTouch)&&r.vars.touch,u="click touchend MSPointerUp keyup",a="",f,l=r.vars.direction==="vertical",c=r.vars.reverse,h=r.vars.itemWidth>0,p=r.vars.animation==="fade",d=r.vars.asNavFor!=="",v={},m=true;e.data(t,"flexslider",r);v={init:function(){r.animating=false;r.currentSlide=parseInt(r.vars.startAt?r.vars.startAt:0,10);if(isNaN(r.currentSlide))r.currentSlide=0;r.animatingTo=r.currentSlide;r.atEnd=r.currentSlide===0||r.currentSlide===r.last;r.containerSelector=r.vars.selector.substr(0,r.vars.selector.search(" "));r.slides=e(r.vars.selector,r);r.container=e(r.containerSelector,r);r.count=r.slides.length;r.syncExists=e(r.vars.sync).length>0;if(r.vars
@EnragedSuccubus
EnragedSuccubus / wp-config.php
Created October 29, 2014 19:07
WordPress Dev configurations
<?php
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* Add this above "That's all, stop editing! Happy blogging."
*/
@EnragedSuccubus
EnragedSuccubus / functions.php
Created September 5, 2015 00:05
Revert jQuery back a version so ACF works in WordPress 4.3
function cg_revert_jquery_version_admin() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js');
wp_enqueue_script( 'jquery' );
}
add_action( 'admin_enqueue_scripts', 'cg_revert_jquery_version_admin' );
@EnragedSuccubus
EnragedSuccubus / input.js
Created September 5, 2015 00:48
Fixing ACF Pro so the dreded "isArrayLike empty obj error" is avoided
acf.add_filter('validation_complete', function( json, $form ){
// Return early if there are no errors.
// This will avoid the dreded "isArrayLike empty obj error"
// https://github.com/jquery/jquery/issues/2242
if ( 0 === json.errors ) {
return json;
}
// show field error messages
/**
* Automobile interface
*
* Creates a contract that any class implementing this interface must abide by
*/
interface Automobile {
/**
* steering_wheel function
*
* @access public
@EnragedSuccubus
EnragedSuccubus / php-interfaces-eg02.php
Last active January 5, 2016 03:51
PHP Interfaces eg 02
/**
* Class CarA
*/
class CarA implements Automobile {
protected $specs;
/**
* Constructor
*
* @param object $specs The object of data defining Car A
@EnragedSuccubus
EnragedSuccubus / build-hollow-box-css3-eg02.css
Last active January 5, 2016 04:37
Build Hollow Box CS3 EG 02
.box {
width:200px;
height:200px;
background-color:#DC403B
}