Skip to content

Instantly share code, notes, and snippets.

View ramiabraham's full-sized avatar

Rami Abraham ramiabraham

View GitHub Profile
<?php
/**
* Disable all non-whitelisted jetpack modules.
*
* This will allow all of the currently available Jetpack modules to work
* normally. If there's a module you'd like to disable, simply comment it out
* or remove it from the whitelist and it will no longer load.
*
* @author FAT Media, LLC
* @link http://wpbacon.com/tutorials/disable-jetpack-modules/
<?php
/**
* Plugin Name: Static Templates
*
* If most of your site content is in .php template files, and you're tired of
* creating new pages, assigning them page templates, creating page templates
* then doing it all over again on production, this plugin is for you.
*
* Examples:
*
@ramiabraham
ramiabraham / edd.php
Last active August 29, 2015 14:07 — forked from amdrew/edd.php
<?php
/**
* Disable commission on an entire product category in Easy Digital Downloads
*/
function affwp_custom_wc_disable_commission_per_category( $referral_amount, $affiliate_id, $amount, $reference, $product_id ) {
// Array of categories to disable commission for. Separate by a comma and use either the term name, term_id, or slug
$disabled_categories = array( 'category-one', 5 );
@ramiabraham
ramiabraham / set-affwp-reg-role.php
Last active August 29, 2015 14:20 — forked from pippinsplugins/gist:d973776836ab984aea06
Set affiliate role on registration
<?php
/*
* Plugin name: Affiliate role on registration
*/
function pw_affwp_set_role_on_registration( $affiliate_id = 0 ) {
$user_id = affwp_get_affiliate_user_id( $affiliate_id );
$user = new WP_User( $user_id );
$user->add_role( 'affiliate' );
<?php
/*-----------------------------------------------------------------------------------*/
/* Conditional Logic to Detect Various Event Related Views/Pages
/*-----------------------------------------------------------------------------------*/
if( tribe_is_month() && !is_tax() ) { // Month View Page
echo 'were on the month view page';
} elseif( tribe_is_month() && is_tax() ) { // Month View Category Page

Setting up a WordPress site on AWS

This tutorial walks through setting up AWS infrastructure for WordPress, starting at creating an AWS account. We'll manually provision a single EC2 instance (i.e an AWS virtual machine) to run WordPress using Nginx, PHP-FPM, and MySQL.

This tutorial assumes you're relatively comfortable on the command line and editing system configuration files. It is intended for folks who want a high-level of control and understanding of their infrastructure. It will take about half an hour if you don't Google away at some point.

If you experience any difficulties or have any feedback, leave a comment. 🐬

Coming soon: I'll write another tutorial on a high availability setup for WordPress on AWS, including load-balancing multiple application servers in an auto-scaling group and utilizing RDS.

@ramiabraham
ramiabraham / nginx.conf
Last active August 29, 2015 14:25 — forked from plentz/nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048

Disable Plugins

Quickly disable all plugins in WordPress.

Usage

This plugin needs to go into the wp-content/mu-plugins/ directory. Provided you have SSH access to the server where WordPress lives, you can do this:

cd $SITE_ROOT/wp-content/mu-plugins
@ramiabraham
ramiabraham / togetherjs.php
Last active December 25, 2015 15:59 — forked from anonymous/togetherjs.php
Just a plugin to load together.js in WP.
<?php
/*
Plugin Name: TogetherJS for WordPress
Plugin URI: http://www.rami.nu
Description: Integrates TogetherJS with WordPress
Version: 0.1
Author: ramiabraham
Author URI: http://rami.nu
License: GPL 2.0
*
@ramiabraham
ramiabraham / ask.sh
Created May 17, 2016 17:19
Bash: General-purpose Yes/No prompt function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# http://djm.me/ask
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"