Skip to content

Instantly share code, notes, and snippets.

Aaron Ranard aaronranard

Block or report user

Report or block aaronranard

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
@aaronranard
aaronranard / _icons-material-design.scss
Created Jun 16, 2015
SCSS: Materialize icons gulp build fix
View _icons-material-design.scss
$font-mdi : 'Material-Design-Icons';
$mdi-prefix : 'mdi-';
@font-face {
font-family: "#{$font-mdi}";
src:url("#{$icons-font-path}#{$font-mdi}.eot?#iefix") format("embedded-opentype"),
url("#{$icons-font-path}#{$font-mdi}.woff2") format("woff2"),
url("#{$icons-font-path}#{$font-mdi}.woff") format("woff"),
url("#{$icons-font-path}#{$font-mdi}.ttf") format("truetype"),
url("#{$icons-font-path}#{$font-mdi}.svg##{$font-mdi}") format("svg");
@aaronranard
aaronranard / file-upload.js
Last active Aug 29, 2015
Angular: File Uploader
View file-upload.js
$scope.onFileSelect = function($files) {
// https://github.com/danialfarid/angular-file-upload
var file = $files[0];
$scope.upload = $upload.upload({
url: apiEndpoint + '/api/file/upload',
// method: 'POST' or 'PUT',
// headers: {'header-key': 'header-value'},
// withCredentials: true,
//data: {myObj: $scope.myModelObj},
file: file, // or list of files: $files for html5 only
@aaronranard
aaronranard / input-max-length.js
Last active Apr 24, 2019
Angular: directive to limit an input field to a max number of characters
View input-max-length.js
app.directive('inputMaxlength', function() {
return {
require: 'ngModel',
link: function (scope, element, attrs, ngModelCtrl) {
var maxlength = Number(attrs.inputMaxlength);
function fromUser(text) {
if (text.length > maxlength) {
var transformedInput = text.substring(0, maxlength);
ngModelCtrl.$setViewValue(transformedInput);
ngModelCtrl.$render();
@aaronranard
aaronranard / cookies.js
Last active Aug 29, 2015
Javascript: Cookie Management
View cookies.js
/**
* determine whether this is the first visit to the animation page
* @param {string} c_name cookie name
* @return {string} cookie value
*/
function getCookie(c_name){
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start === -1){
c_start = c_value.indexOf(c_name + "=");
@aaronranard
aaronranard / acf-gallery-lightbox.php
Created Apr 8, 2014
WordPress: ACF - Lightbox Gallery
View acf-gallery-lightbox.php
@aaronranard
aaronranard / acf-gallery.php
Created Apr 8, 2014
WordPress: ACF - Output Gallery
View acf-gallery.php
@aaronranard
aaronranard / custom-taxonomies.php
Last active Aug 29, 2015
WordPress - get custom taxonomies for post
View custom-taxonomies.php
$categories = get_the_terms( get_the_id() , 'service' );
$separator = '<br />';
$output = '';
if($categories){
foreach($categories as $category) {
//$output .= '<a href="'.get_category_link( $category->term_id ).'" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $category->name ) ) . '">'.$category->cat_name.'</a>'.$separator;
$output .= $category->name . $separator;
}
echo trim($output, $separator);
}
@aaronranard
aaronranard / is_child.php
Created Nov 26, 2013
WordPress: is a child page
View is_child.php
/**
* Child page conditional
* @ Accept's page ID, page slug or page title as parameters
*/
function is_child( $parent = '' ) {
global $post;
$parent_obj = get_page( $post->post_parent, ARRAY_A );
$parent = (string) $parent;
$parent_array = (array) $parent;
@aaronranard
aaronranard / search_functions.php
Created Sep 20, 2013
WordPress - Blank Search to go to search.php
View search_functions.php
//For blank searches to use search.php
add_filter( 'request', 'my_request_filter' );
function my_request_filter( $query_vars ) {
if( isset( $_GET['s'] ) && empty( $_GET['s'] ) ) {
$query_vars['s'] = " ";
}
return $query_vars;
}
@aaronranard
aaronranard / repeater.php
Last active Dec 22, 2015
WordPress: Repeater Field Loop
View repeater.php
<?php if(have_rows('repeater_field_name')): ?>
<ul>
<?php while( have_rows('repeater_field_name')): the_row(); ?>
<li><?php echo get_sub_field('image'); ?></li>
<?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
<?php endwhile; ?>
</ul>
<?php endif; ?>
You can’t perform that action at this time.