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 | |
/* Example Usage: | |
* bt_add_image_size( 'product-screenshot', 300, 300, array( 'left', 'top' ) ); | |
* bt_add_image_size( 'product-feature', 460, 345, array( 'center', 'top' ) ); | |
*/ | |
add_filter( 'intermediate_image_sizes_advanced', 'bt_intermediate_image_sizes_advanced' ); | |
add_filter( 'wp_generate_attachment_metadata', 'bt_generate_attachment_metadata', 10, 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
<?php | |
function bt_register_routes( $routes ) { | |
foreach ( $routes as $route_name => $args ) { | |
bt_register_route( $route_name, $args ); | |
} | |
} | |
function bt_register_route( $route_name, $args = array() ) { | |
$args = wp_parse_args( $args, array( | |
'query_var' => 'route_' . $route_name, |
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 | |
NOW=$(date +%Y%m%d%H%M%S) | |
SQL_FILE=${NOW}_database.sql | |
# Backup database | |
wp db export ../backups/$SQL_FILE --add-drop-table | |
# Compress the database file | |
gzip ../backups/$SQL_FILE |
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 | |
class DBrains_Auto_Login { | |
protected static $_instance = null; | |
function __construct() { | |
global $wpdb; | |
$this->expires = DAY_IN_SECONDS * 30 * 4; | |
$this->table = $wpdb->prefix . 'dbrns_auto_login_keys'; |
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 | |
class WPAS_Model_Order_Meta extends WPAS_Model { | |
static $primary_key = 'order_id'; | |
static function set_as_refunded( $order_id ) { | |
$data = array( 'is_refunded' => 1 ); | |
$where = array( 'order_id' => $order_id ); | |
self::update( $data, $where ); | |
} |
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 | |
BUCKET_NAME=${1-''} | |
# Get upload folder path using WP-CLI | |
# We use --url=http://blah.com in our WP-CLI commands so that we don't get the PHP warning about HTTP_HOSTS | |
UPLOADS_PATH=$(wp eval '$upload_dir = wp_upload_dir(); echo $upload_dir["basedir"];' --url=http://blah.com 2>&1) | |
if [[ $UPLOADS_PATH =~ Error ]] | |
then |
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
# Setting up dnsmasq for Local Web Development Testing on any Device | |
Please note, these instructions are for OS X Lion. | |
First, you need to get the IP address of your machine on your local network. In OS X, the easiest place to find this is in System Preferences > Network. If you're using DHCP on your local network, you will want to make sure your computer requests the same IP address when it renews it's IP address lease. I recommend configuring the DCHP Reservation settings on your router to accomplish this. Otherwise, you can specify a manual address in your network settings: | |
1. Go to *System Preferences > Network* | |
1. Click *Advanced...* |
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
#!/usr/bin/php | |
<?php | |
set_time_limit(0); | |
// Get the Drip API wrapper at https://github.com/DripEmail/drip-php | |
require __DIR__ . '/Drip_API.class.php'; | |
$drip = new Drip_API( 'xxxxxxxxxxxxxx' ); | |
$drip_account_id = 0000000; |
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
$( document ).ready( function() { | |
var cookie_name = 'dbrains-coupon'; | |
var cookie_name_error = 'dbrains-coupon-error'; | |
if ( 'undefined' === typeof $.cookie( cookie_name ) ) { | |
return; | |
} | |
var message = 'The coupon code ' + $.cookie( cookie_name ).toUpperCase() + ' has been successfully applied.'; |
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 | |
cd ~/db-backups | |
# Configure your database info | |
DB_NAME=sample_db | |
DB_USERNAME=sample_user | |
DB_PASSWORD=sample_pw | |
# Configure the name of the file |
NewerOlder