This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function parse_youtube_url($url){ | |
$id = ''; | |
preg_match("/^.*(youtu.be\\/|v\\/|u\\/\\w\\/|embed\\/|watch\\?v=|\\&v=)([^#\\&\\?]*).*/uism", $url, $matches); | |
if( isset($matches[2]) ){ | |
$id = $matches[2]; | |
} | |
return $id; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var regex = /^.+@.+\..+$/; | |
var tests = Array( '[email protected]', 'testATtest.com', 'test@testDOTcom', | |
'[email protected]', '[email protected]', '[email protected]'); | |
for(var i = 0; i < tests.length; i++){ | |
var result = regex.exec( tests[i] ); | |
console.log('Testing: ' + tests[i]); | |
if( result ){ | |
console.log('match found\n'); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function close_flexible_content(){ | |
$('.layout').attr('data-toggle', 'closed'); | |
$('.acf-input-table').css('display', 'none'); | |
} | |
function open_flexible_content(){ | |
$('.layout').attr('data-toggle', 'open'); | |
$('.acf-input-table').css('display', 'table'); | |
} | |
close_flexible_content(); | |
$('.field_type-flexible_content').prepend('<a class="toggle_flexible_content button button-small" style="float: right; margin-top: -8px;" href="#">Toggle Layout Boxes</a>') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$array = array(0, 1, 2, 3); | |
$string = print_r($array, true); | |
$filename = sha1( $string ) . ".sha1"; | |
echo $filename . PHP_EOL; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Get a new larger proportional height and width for an image | |
* Adapted from http://stackoverflow.com/a/4820929/648844 | |
* | |
* Parameters: original width, original height, minimum width, minimum height | |
* Return: null if image exceeds minimums or array with rounded width and height | |
*/ | |
function image_resize_up($orig_w, $orig_h, $MIN_W, $MIN_H){ | |
$ratio = $orig_w * 1.0 / $orig_h; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | |
<title>Google Maps Multiple Markers</title> | |
<script src="http://maps.google.com/maps/api/js?sensor=false"></script> | |
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.1.min.js"></script> | |
</head> | |
<body> | |
<div id="map" style="width: 500px; height: 400px;"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add custom taxonomy terms to body class | |
function section_taxonomy_in_body_class( $classes ){ | |
if( is_singular() ) | |
{ | |
global $post; | |
$custom_terms = get_the_terms($post->ID, 'subsite'); | |
if ($custom_terms) { | |
foreach ($custom_terms as $custom_term) { | |
$classes[] = 'section_' . $custom_term->slug; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Check if checkbox should be checked based on GET value | |
*/ | |
function isChecked($chkname,$value) { | |
if(!empty($_GET[$chkname])){ | |
foreach($_GET[$chkname] as $chkval){ | |
if($chkval == $value){ | |
return true; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$post_type = 'post'; | |
// Get all the taxonomies for this post type | |
$taxonomies = get_object_taxonomies( (object) array( 'post_type' => $post_type ) ); | |
foreach( $taxonomies as $taxonomy ){ | |
// Gets every "category" (term) in this taxonomy to get the respective posts | |
$terms = get_terms( $taxonomy ); | |
foreach( $terms as $term ){ | |
echo $term->name; | |
} |