Skip to content

Instantly share code, notes, and snippets.

John Hartley johnbhartley

Block or report user

Report or block johnbhartley

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
@johnbhartley
johnbhartley / mb-do-shortcode
Created Aug 18, 2014
MaxButtons do_shortcode
View mb-do-shortcode
<?php echo do_shortcode('[maxbutton id="17" text="Search Google" url="http://google.com"]'); ?>
@johnbhartley
johnbhartley / lat-long-distance
Last active Aug 29, 2015
Distance between lat/long coordinates
View lat-long-distance
<script>
// from http://html5doctor.com/finding-your-position-with-geolocation/
if (navigator.geolocation) {
var timeoutVal = 10 * 1000 * 1000;
navigator.geolocation.getCurrentPosition(
displayPosition,
displayError,
{ enableHighAccuracy: true, timeout: timeoutVal, maximumAge: 0 }
);
}
@johnbhartley
johnbhartley / first-word
Created Jul 18, 2014
Span the first word ya dingus
View first-word
$string = 'Test me more';
$pattern = '/^(\S+)/';
$replacement = '<span class="first-word">$1</span>';
echo preg_replace($pattern, $replacement, $string);
// or
echo preg_replace('/^(\S+)/', '<span class="first-word">$1</span>', 'Test me more');
// from @greg5green
@johnbhartley
johnbhartley / round-down-clown-frown
Created Jul 3, 2014
Round down to nearest hundred
View round-down-clown-frown
$min = 780;
$floor = 780/100; // 7.8
$floor_fix = floor($floor); // 7.0
$min = $floor_fix*100; // 700
echo $min; // will output 700
View gist:be54cfddfc5faf6ec4cc
<div class="rrssb-buttons">
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" class="popup facebook">
<span class="icon">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="28px" height="28px" viewBox="0 0 28 28" enable-background="new 0 0 28 28" xml:space="preserve">
<path class="path" d="M27.825,4.783c0-2.427-2.182-4.608-4.608-4.608H4.783c-2.422,0-4.608,2.182-4.608,4.608v18.434
c0,2.427,2.181,4.608,4.608,4.608H14V17.379h-3.379v-4.608H14v-1.795c0-3.089,2.335-5.885,5.192-5.885h3.718v4.608h-3.726
c-0.408,0-0.884,0.492-0.884,1.236v1.836h4.609v4.608h-4.609v10.446h4.916c2.422,0,4.608-2.188,4.608-4.608V4.783z"/>
</svg>
</span>
<span class="text">Share on Facebook</span>
@johnbhartley
johnbhartley / fa-array
Created Jun 9, 2014
Font Awesome Icons Array - Title Only
View fa-array
$icon_array = array(
'fa-glass',
'fa-music',
'fa-search',
'fa-envelope-o',
'fa-heart',
'fa-star',
'fa-star-o',
'fa-user',
'fa-film',
@johnbhartley
johnbhartley / 50-states
Created May 20, 2014
List of 50 States
View 50-states
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
Florida
Georgia
View simple-rotator
// jQuery
function cycleReviews(){
var $active = $('.content-slider .current');
var $next = ($active.next().length > 0) ? $active.next() : $('.content-slider div:first');
$active.fadeOut(500,function(){
$(this).removeClass('current');
$next.fadeIn().addClass('current');
});
@johnbhartley
johnbhartley / Unclickable links
Created May 30, 2013
Make links unclickable through jQuery...quick fix, but probably not the best way
View Unclickable links
@johnbhartley
johnbhartley / gist:5005299
Last active Dec 14, 2015
Public MG Pagination
View gist:5005299
<?php
//grabbed from image.php in TwentyTwelve...credit where credit's due
/**
* Grab the IDs of all the image attachments in a gallery so we can get the URL of the next adjacent image in a gallery,
* or the first image (if we're looking at the last image in a gallery), or, in a gallery of one, just the link to that image file
*/
$attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) );
foreach ( $attachments as $k => $attachment ) :
if ( $attachment->ID == $post->ID )
You can’t perform that action at this time.