This file contains 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 | |
/* | |
Using WordPress as a REST API endpoint (vs AJAX Admin) | |
-- with caching using the Transient API -- | |
forked from: Pete Nelson @GunGeekATX | |
1) Create a page called API in WordPres | |
2) Create a file called page-api.php in your theme directory | |
3) Build custom endpoints |
This file contains 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
<div class="loader"></div> |
This file contains 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 hidden | |
, visibilityChange | |
// browser prefixes | |
if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support | |
hidden = "hidden" | |
visibilityChange = "visibilitychange" | |
} else if (typeof document.mozHidden !== "undefined") { | |
hidden = "mozHidden" | |
visibilityChange = "mozvisibilitychange" |
This file contains 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 extend(){ | |
var output = {}, | |
args = arguments, | |
l = args.length; | |
for ( var i = 0; i < l; i++ ) | |
for ( var key in args[i] ) | |
if ( args[i].hasOwnProperty(key) ) | |
output[key] = args[i][key]; | |
return output; |
This file contains 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
/************************************************************************** | |
Perlin Noise | |
from https://gist.github.com/banksean/304522, in angular wrapper | |
**************************************************************************/ | |
(function(window, angular, undefined){ 'use strict'; |
This file contains 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
#!/bin/bash | |
# PRE SETUP: create bkpath dir, ie /user/backups. suggested: put this script there. | |
name="" # set this to the name of the project | |
bkpath="/var/backups/" # directory to store backups in locally | |
# Grab a DB dump from the MySQL server -> $bkpath/db/name_YYYY-MM-DD.sql | |
MYSQLDUMP="$(which mysqldump)" |
This file contains 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
/* have to use intrinsic ratio: http://alistapart.com/article/creating-intrinsic-ratios-for-video */ | |
.svg-container { | |
width: 100%; | |
display: block; | |
height: auto; | |
position: relative; | |
padding-top: 100%; // ratio: w/h*100 | |
} |
This file contains 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 | |
$imageID = get_field('image_field_name'); // set this field to return Image ID | |
$size = 'full'; // thumbnail, medium, large, full | |
$img = wp_get_attachment_image_src( $imageID, $size ); | |
if( !empty($image) ): | |
$url = $img[0]; | |
$width = $img[1]; |
This file contains 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_action('wp_ajax_myajaxfunctionname', 'ajax_myajaxfunctionname'); | |
add_action('wp_ajax_nopriv_myajaxfunctionname', 'ajax_myajaxfunctionname'); | |
function ajax_myajaxfunctionname(){ | |
$var = $_POST['var']; | |
if( ! isset($var) ) die(1); | |
NewerOlder