Skip to content

Instantly share code, notes, and snippets.

View digiltd's full-sized avatar

Sam Turner digiltd

View GitHub Profile
var dob = "1998-10-10";
if(dob != ''){
var str=dob.split('-');
var firstdate=new Date(str[0],str[1],str[2]);
var today = new Date();
var dayDiff = Math.ceil(today.getTime() - firstdate.getTime()) / (1000 * 60 * 60 * 24 * 365);
var age = parseInt(dayDiff);
$('#age').html(age+' years');
}
@digiltd
digiltd / DefaultKeyBinding.dict
Created June 9, 2015 22:17
A trimmed down selection of Brett Terpstra's set up http://brettterpstra.com/projects/keybindings/
{ // General
// > defaults write -g NSTextKillRingSize -string 6
// replace yank: command with yankAndSelect for use with the kill ring
"^y" = (yankAndSelect:);
// uppercase word
"^U" = (uppercaseWord:, moveWordForward:, moveWordBackward:);
// lowercase word
"^~u" = (lowercaseWord:, moveWordForward:, moveWordBackward:);
// titlecase word
"^T" = (capitalizeWord:, moveWordForward:, moveWordBackward:);
@digiltd
digiltd / google-maps-no-scroll.js
Last active September 11, 2015 23:20
google-maps no-scroll
if ($("#contact").length) {
function initialize() {
var myLatLong = new google.maps.LatLng(40.7526, -73.9797);
var mapOptions = {center: myLatLong,scrollwheel: false,zoom: 13};
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
var marker = new google.maps.Marker({position: myLatLong,map: map,title: "123 Broadway"});
}
google.maps.event.addDomListener(window, 'load', initialize);
}
@digiltd
digiltd / functions.php
Created May 15, 2015 10:47
wordpress remove dashboard widgets per user role
<?php
// source http://www.paulund.co.uk/remove-wordpress-dashboard-widgets
function disable_dashboard_widgets() {
global $current_user;
get_currentuserinfo();
if($current_user->user_level != 1){
remove_meta_box('dashboard_right_now', 'dashboard', 'core');
@digiltd
digiltd / functions.php
Last active August 29, 2015 14:21
wordpress remove dashboard widgets
<?php
// source http://www.paulund.co.uk/remove-wordpress-dashboard-widgets
function disable_dashboard_widgets() {
remove_meta_box('dashboard_right_now', 'dashboard', 'core');
remove_meta_box('dashboard_recent_comments', 'dashboard', 'core');
remove_meta_box('dashboard_incoming_links', 'dashboard', 'core');
remove_meta_box('dashboard_plugins', 'dashboard', 'core');
@digiltd
digiltd / gist:8e12d944b56056f492c1
Created May 11, 2015 21:54
acf repeater field
// check if the repeater field has rows of data
if( have_rows('repeater_field_name') ):
// loop through the rows of data
while ( have_rows('repeater_field_name') ) : the_row();
// display a sub field value
the_sub_field('sub_field_name');
endwhile;
@digiltd
digiltd / functions.php
Created May 8, 2015 11:04
wordpress get_post_categories
$categories = get_the_category();
$separator = ' ';
$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;
}
echo trim($output, $separator);
}
@digiltd
digiltd / functions.php
Last active August 29, 2015 14:20
the_excerpt wordpress custom "read more"
<?php
//adds a link to the post
function custom_excerpt_more_link( $more ) {
return ' <a class="read-more" href="' . get_permalink( get_the_ID() ) . '">' . __( 'Read More', 'your-text-domain' ) . '</a>';
}
add_filter( 'excerpt_more', 'custom_excerpt_more_link' );
@digiltd
digiltd / readme.md
Last active February 4, 2016 01:22
Advanced Custom Fields - Repeater using image fields

ACF Repeater using image fields

This gist is to accompany my comment on Mark's article:

[Build modular content systems in WordPress] (http://www.creativebloq.com/web-design/build-modular-content-systems-wordpress-41514680) by Mark Llobrera

Which if you haven't read (or just stumbled upon this gist by chance) then I highly recomend you do.

It demonstrates some key concepts on how you can use ACF to build your clients mini page builders. By doing so you can avoid all the bloat that the big page builder type plugins use. You will also build up your own mini library of elements that you can reuse depending on the project.

@digiltd
digiltd / functions.php
Last active August 29, 2015 14:19
disable WordPress Dashboard widgets
// disable default dashboard widgets
function disable_default_dashboard_widgets() {
global $current_user;
get_currentuserinfo();
if($current_user->user_level != 1){
remove_meta_box('dashboard_right_now', 'dashboard', 'core');
remove_meta_box('dashboard_activity', 'dashboard', 'core');