Skip to content

Instantly share code, notes, and snippets.

View kurtschlatzer's full-sized avatar

Kurt Schlatzer kurtschlatzer

View GitHub Profile
$subdomains = ['atlanta', 'berkeley', 'columbus'];
foreach ($subdomains as $subdomain) {
if (isset($_ENV['PANTHEON_ENVIRONMENT']) &&
($_SERVER['HTTP_HOST'] == $subdomain . '.yoursite.com') &&
// Check if Drupal or WordPress is running via command line
(php_sapi_name() != "cli")) {
$newurl = 'http://www.yoursite.com/' . $subdomain . '/'. $_SERVER['REQUEST_URI'];
header('HTTP/1.0 301 Moved Permanently');
@kurtschlatzer
kurtschlatzer / README.md
Created December 20, 2017 17:23 — forked from magnetikonline/README.md
Linux umask table.

Linux umask table

Umask is determined by subtracting (binary NOT) from initial masks of:

  • File: 666 rw-rw-rw
  • Directory: 777 rwxrwxrwx
Umask File result Directory result
000 666 rw-rw-rw- 777 rwxrwxrwx
002 664 rw-rw-r-- 775 rwxrwxr-x
022 644 rw-r--r-- 755 rwxr-xr-x
@kurtschlatzer
kurtschlatzer / patch-edid.md
Last active October 13, 2023 06:46 — forked from ejdyksen/patch-edid.md
Fix EDID problems on external monitors in Mac OS.
@kurtschlatzer
kurtschlatzer / functions.php
Created March 28, 2017 20:53 — forked from WooForce/functions.php
Adjusting puerto rico as state
function wf_remove_puerto_rico_country( $country ) {
if(array_key_exists('PR', $country))
{
unset($country['PR']);
}
return $country;
}
add_filter( 'woocommerce_countries', 'wf_remove_puerto_rico_country', 10, 1 );
function wf_add_puerto_to_us_states( $states ) {
@kurtschlatzer
kurtschlatzer / how-to-batch-convert-jpg-images-to-progressive-jpg-images.md
Created January 17, 2017 01:07 — forked from nepsilon/how-to-batch-convert-jpg-images-to-progressive-jpg-images.md
How to batch convert JPG images to progressive JPG images? — First published in fullweb.io issue #82

How to batch convert JPG images to progressive JPG images?

Progressive JPG images, as opposed to baseline JPG, will display right away in the browser, and will load bits of it in cycle, rendering it from blur to clear.

Progressive is known to provide a better user experience, preventing the ”fax loading” effect. Where the image is displayed in full, but sequentially from top to bottom.

The imagemagick package will install the convert command that you can run to convert JPG to progressive:

convert -strip -interlace Plane -quality 80 input-file.jpg output-file.jpg
@kurtschlatzer
kurtschlatzer / gist:4509d5d0b71e42084dddd31d223071c5
Created January 10, 2017 20:16 — forked from kloon/gist:4541017
WooCommerce Clear Cart via URL
// check for clear-cart get param to clear the cart, append ?clear-cart to any site url to trigger this
add_action( 'init', 'woocommerce_clear_cart_url' );
function woocommerce_clear_cart_url() {
if ( isset( $_GET['clear-cart'] ) ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
}
}
@kurtschlatzer
kurtschlatzer / get-woocommerce-categories.php
Created December 20, 2016 21:31 — forked from rajeebbanstola/get-woocommerce-categories.php
Simple way to fetch WooCommerce Categories with Image and Description
<?php
$get_featured_cats = array(
'taxonomy' => 'product_cat',
'orderby' => 'name',
'hide_empty' => '0',
'include' => $cat_array
);
$all_categories = get_categories( $get_featured_cats );
$j = 1;
<?php
/**
* Plugin Name: WooCommerce Subscriptions Remove Deprecation Handlers
* Plugin URI: https://support.woothemes.com/hc/en-us/articles/205214466
* Description: Do not load backward compatibility support in Subscriptions 2.0.
* Author: Prospress Inc.
* Version: 1.0
* Author URI: http://prospress.com
*/
<?php
/**
* Rewrite Shop Categories
*
* @wordpress-plugin
* Plugin Name: Rewrite Shop Categories
* Description: Allows categories and products both to have 'shop' base
* Author: Plant Ninja
*/
@kurtschlatzer
kurtschlatzer / functions.php
Created October 20, 2016 18:37 — forked from dleone81/functions.php
Woocommerce get product type
/**
* is_type can be simple, variable, grouped, external
* woocommerce_single_product_summary is hook!
* Put this into your functions.php (child-theme)
**/
add_action( 'woocommerce_single_product_summary', 'get_product_type', 5 );
function get_product_type() {
global $post;
if( function_exists('get_product') ){
$product = get_product( $post->ID );