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 /* | |
Takes a product ID and returns an array that includes all types of variations of the product, and the attributes of that variation. | |
Variations are normally returned as a term object. They belong to the original product ID and the taxonomy name is equal to the attribute name. | |
If a custom variation is provided instead of a term object, the variation will simply be a string of the option's name. | |
Example return result is given below. This is a single product with one attribute and two different variations. | |
Array ( | |
[pa_oregon-training-classes] => Array ( | |
[attribute] => Array ( |
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 | |
// Disable sanitization of specific fields by removing the sanitization filter hooks | |
// Note that at least one filter must exist for the field to be saved. | |
function optionsframework_remove_sanitization() { | |
// Text areas | |
remove_filter( 'of_sanitize_textarea', 'of_sanitize_textarea' ); | |
add_filter( 'of_sanitize_textarea', function ($input) { return $input; }); | |
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
/* | |
HOW TO USE: | |
0. Ensure the admin page has enqueue the media library scripts. Here is an example to include it on the "Page" edit screen (post.php): | |
function page_enqueue_media_scripts() { | |
$screen = get_current_screen(); | |
if ( $screen->base == 'post' && $screen->id == 'page' ) wp_enqueue_media(); | |
} | |
add_action('admin_enqueue_scripts', 'page_enqueue_media_scripts'); |
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 | |
// This function quickly grabs the 10 digit phone number from a string. | |
// Works with most user input. | |
// Standard US phone number format only. | |
// Note: For storage, always store what the user gives you (ex: 555-123-1234 until 5pm, after that call 555-123-1234) | |
function extract10digitphone( $str, $format = '(%s) %s-%s' ) { | |
$regex = '/([0-9]{3}).*([0-9]{3}).*([0-9]{4})/mU'; | |
if ( preg_match( $regex, $str, $match ) ) { |
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
// Bookmarklet: | |
// javascript:(function()%7Bif%20(%20jQuery('%23createuser').length%20)%20%7Bvar%20previous_creds%20%3D%20prompt('Enter%20previous%20setup%20code%20(or%20click%20enter%20to%20skip)'%2C%20'')%3Bvar%20username%20%3D%20false%3Bvar%20email%20%3D%20false%3Bvar%20password%20%3D%20false%3Bvar%20firstname%20%3D%20false%3Bvar%20lastname%20%3D%20false%3Bvar%20website%20%3D%20false%3Bvar%20role%20%3D%20false%3Bif%20(%20previous_creds%20)%20%7Bvar%20creds%20%3D%20jQuery.parseJSON(%20previous_creds%20)%3Bif%20(%20creds%20)%20%7Busername%20%3D%20creds.username%3Bemail%20%3D%20creds.email%3Bpassword%20%3D%20creds.password%3Bif%20(%20creds.firstname%20)%20firstname%20%3D%20creds.firstname%3Bif%20(%20creds.lastname%20)%20lastname%20%3D%20creds.lastname%3Bif%20(%20creds.website%20)%20website%20%3D%20creds.website%3Bif%20(%20creds.role%20)%20role%20%3D%20creds.role%3B%7D%7Dif%20(%20!previous_creds%20%7C%7C%20!username%20%7C%7C%20!email%20%7C%7C%20!password%20)%20%7Bvar%20username%20%3D%20prompt('(Step%201%2F8)%2 |
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 | |
# Upload a backup file to external FTP. Delete local copy if successful. | |
# CONFIGURATION ---------- | |
LOCALPATH='/path/to/backup' | |
HOST='' | |
USER='' | |
PASS='' | |
REMOTEPATH='/remote/storage/path' | |
# RUN PROGRAM ------------ |
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
/* | |
This function allows you to press and drag your mouse over multiple checkboxes to change the state of them all. | |
It does not toggle, but instead causes any selected values to match the originating element. | |
Does not support radio buttons or dynamically loaded elements. | |
Example Usage -- Say you have five checkboxes, with the middle one checked: | |
[0] | |
[0] |
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 | |
$recent_weather = get_transient('recent_weather_widget'); | |
if ( !$recent_weather ) { | |
$api_key = 'YOUR_API_KEY'; | |
$lat = '44.052303'; | |
$long = '-123.102148'; | |
$cache_duration = 60*30; // seconds | |
// retrieve weather information from forecast.io |
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 | |
/* | |
Format: | |
array( | |
group_key => ( | |
post_type = TYPES, | |
args = ARGS, | |
fields = FIELDS, |