Skip to content

Instantly share code, notes, and snippets.

View zeraphie's full-sized avatar

Izzy Skye zeraphie

View GitHub Profile
@zeraphie
zeraphie / excerptify.php
Created March 29, 2016 15:24
Make any text 'excerpty'
<?php
// Make any text 'excerpty'
function excerptify($text, $length = 140){
return trim(substr($text, 0, strpos($text, ' ', $length))) . '...';
}
@zeraphie
zeraphie / todays_item.php
Created March 8, 2016 15:32
Get today's item from a list of items
function todays_item($arr){
$count = count($arr);
$number = floor(time() / 86400) % $count;
return $arr[$number];
}
$arr = array(
'One',
'Two',
'Three'
@zeraphie
zeraphie / is_prime.php
Created March 8, 2016 15:15
Test if a number is prime 1-liner
function is_prime($number) {
return !preg_match('/^1?$|^(11+?)\1+$/x', str_repeat('1', $number));
}
@zeraphie
zeraphie / breadcrumbs.php
Created March 8, 2016 11:31
Wordpress Breadcrumbs
<?php
/**
* Echos out the html for breadcrumbs
*
* @return string
*/
function get_breadcrumbs($separator = '>', $home_title = 'Homepage', $breadcrums_id = 'breadcrumbs', $breadcrums_class = 'breadcrumbs') {
// If you have any custom post types with custom taxonomies, put the taxonomy name below (e.g. product_cat)
$custom_taxonomy = '';
<?php
$consumerKey = /*CONSUMER KEY*/;
$consumerSecret = /* CONSUMER SECRET*/;
$authContext = stream_context_create(array(
'http' => array(