Skip to content

Instantly share code, notes, and snippets.

View polevaultweb's full-sized avatar

Iain Poulson polevaultweb

View GitHub Profile
@polevaultweb
polevaultweb / htaccess_image_sync
Last active August 29, 2015 14:03
WordPress .htaccess images
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) http://livesite.com/wp-content/uploads/$1 [L,P]
</IfModule>
@polevaultweb
polevaultweb / site_functions.php
Last active August 29, 2015 14:06
This is a plugin that allows you to tweak the functionality of Instagrate Pro plugin. Add it to your wp-content/plugins folder and activate as you would a normal plugin
<?php
/*
Plugin Name: Site Functions
Description: Functionality changes to WordPress, plugins, and themes instead of using functions.php.
Version: 0.1
License: GPL
Author: Your Name
Author URI: yoururl
*/
@polevaultweb
polevaultweb / custom_as3cf_upload.php
Last active August 31, 2015 16:55
Custom image upload to Amazon S3
add_action('admin_init', 'base_file');
function base_file() {
$parent_post_id = 0;
$upload_dir = wp_upload_dir();
// @new
$upload_path = str_replace( '/', DIRECTORY_SEPARATOR, $upload_dir['path'] ) . DIRECTORY_SEPARATOR;
@polevaultweb
polevaultweb / wpmdb_profile_id_edits.php
Last active August 29, 2015 14:14
Edit profile IDs for WP Migrate DB Pro
<?php
add_action( 'admin_init', 'wpmdb_tweak_profile_id_edit' );
function wpmdb_tweak_profile_id_edit() {
$profile_mappings = array(
2 => 1,
3 => 2,
);
$wpmdb_settings = get_site_option( 'wpmdb_settings' );
@polevaultweb
polevaultweb / activate_sellwire.php
Last active January 6, 2018 13:49
Activate Sellwire License
<?php
$sellwire_url = 'https://app.sellwire.net/api/1/';
$api_params = array(
'license' => $license,
'file' => $file_id
);
$response = wp_remote_get( add_query_arg( $api_params, $sellwire_url . 'activate_license' ), $this->license_args() );
if ( is_wp_error( $response ) ) {
@polevaultweb
polevaultweb / bulk_blogs.sh
Last active August 29, 2015 14:23
Create bulk amount of blogs in a WordPress Multisite
#!/usr/bin/env bash
cd /Applications/MAMP/htdocs/dbtestingmssd/
for i in {1..150}
do
wp site create --slug="test$i"
done
@polevaultweb
polevaultweb / wp-install-core-sub-dir.sh
Last active November 8, 2023 01:30
This script installs WordPress inside a sub directory
#!/bin/bash
# Installation:
## Download the script to your home directory
# Make sure it has execute permissions (`chmod +x wp-install-core-sub-dir.sh`).
# Install the script in one of the folders in your PATH. (`mv wp-install-core-sub-dir.sh /usr/local/bin/wp-install-core-sub-dir`)
#Usage:
<?php
/*
Plugin Name: WP Offload S3 - Relative URL Find & Replace
Description: Find and replace relative local URLs with S3 URLs in post content after they have been uploaded to S3
Author: Delicious Brains
Version: 1.0
Author URI: https://deliciousbrains.com/
*/
add_action( 'admin_init', 'wpos3rel_find_replace' );
<?php
/**
* Class API
*/
class API extends \WP_UnitTestCase {
/**
* @var \DeliciousBrains\Offload\AWS\API
*/
@polevaultweb
polevaultweb / wpos-copy-hidpi-images.php
Created January 8, 2016 16:03
Restores the functionality of copying of HiDPI (@2x) images during S3 offload of attachments.
<?php
/*
Plugin Name: WP Offload S3 - Copy HiDPI Images
Description: Restores the functionality of copying of HiDPI (@2x) images during S3 offload of attachments.
Author: Delicious Brains
Version: 1.0
Author URI: https://deliciousbrains.com/
*/
add_filter( 'as3cf_attachment_file_paths', 'wpos3_hipdi_add_hidpi_file_paths' );