Skip to content

Instantly share code, notes, and snippets.

View gschoppe's full-sized avatar

Greg Schoppe gschoppe

View GitHub Profile
@gschoppe
gschoppe / bad-matt.php
Last active November 8, 2024 15:43
This is a protest plugin in response to the unacceptable behavior of Matt Mullenweg (BDFL of WordPress). In a propaganda interview, Matt claimed that one of the unacceptable things that WPEngine did was to strip out the stripe partner id from woocommerce's stripe gateway plugin. Not only does this appear to be false, but it is in no way a violat…
<?php defined('ABSPATH') or die();
/*
* Plugin Name: Bad Matt
* Plugin URI: https://gschoppe.com
* Description: A protest plugin that removes (or replaces via filter) the Automattic-owned woocommerce stripe gateway partner id.
* Version: 1.0.0
* Requires at least: 4.0
* Requires PHP: 7.2
* Author: Greg Schoppe
* Author URI: https://gschoppe.com/
@gschoppe
gschoppe / Class-CropInterface.js
Last active January 31, 2021 17:21
A simple class to convert a div, or other block-level element, into a zoom and crop interface for images. Sample Implementation: https://codepen.io/gschoppe/pen/xxRxwaO
function CropInterface(el, w, h, resolutionMultiple) {
// handle parameters
this.el = el;
if (!w) { w = 100; }
this.w = w;
if (!h) { h = 100; }
this.h = h;
this.r = w / h;
if (!resolutionMultiple) { resolutionMultiple = 1; }
this.resolutionMultiple = resolutionMultiple;
@gschoppe
gschoppe / Class-ImageScaler.js
Last active January 30, 2021 17:09
A simple JS class to manage client-side cropping. ImageScaler supports setting a focal point for the image, as well as selecting a zoom level for the crop
function ImageScaler(canvas, focus, zoom) {
if (canvas) {
this.canvas = canvas;
} else {
this.canvas = document.createElement("CANVAS");
}
if (focus) {
this.focus = focus;
} else {
this.focus = {x:.5,y:.5};
@gschoppe
gschoppe / Class-IntervalManager.js
Last active January 24, 2021 19:43
Class to simplify management of intervals
function IntervalManager() {
this.intervals = [];
// Public
this.setInterval = function(callback, interval, name) {
if (!name) {
name = "" + Date.now() + "|" + Math.random();
}
var newInterval = {
'name': name,
function DB(projectID) {
this.projectID = projectID;
this.types = {
'INT64' : "INT64",
'NUMERIC' : "NUMERIC",
'BIGNUMERIC': "BIGNUMERIC",
'FLOAT64' : "FLOAT64",
'BOOL' : "BOOL",
'STRING' : "STRING",
@gschoppe
gschoppe / wp_update_watch.php
Created December 6, 2018 16:35
WordPress Update Watch
<?php
if( !empty($_GET['request']) ) {
$current_version = "";
$url = "https://api.wordpress.org/core/version-check/1.7/";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url
));
$result = curl_exec($curl);
@gschoppe
gschoppe / multibox_display_box_dimensions.php
Last active September 20, 2018 13:10
This function will return formatted HTML to display box dimensions and weights for multibox and non-multibox products
<?php
function get_multibox_dimension_output( $product_id = false ) {
$product = wc_get_product( $product_id );
if( !$product ) {
return;
}
$output = '';
$boxes = get_post_meta( $product->ID, '_wc-multibox-additional-boxes', true );
@gschoppe
gschoppe / functions.php
Created August 21, 2018 22:54
Add Featured Image Tag to Timber
<?php
/* populates the twig tag {{ featured_image_tag }} */
add_filter('timber_context', function( $context ){
$context['featured_image_tag'] = get_the_post_thumbnail( null, 'full' );
return $context;
});
@gschoppe
gschoppe / admin-bar-for-weglot.php
Last active October 12, 2018 10:28
Adds a "Translate" button to the admin bar, on post-edit and front end pages, that links directly to the WeGlot visual editor for that page.
<?php if(!defined('ABSPATH')) { die(); }
/*
Plugin Name: Admin Bar for WeGlot
Plugin URI: https://gschoppe.com
Description: Adds an admin bar link to translate any page on your site
Version: 0.1.0
Author: Greg Schoppe
Author URI: https://gschoppe.com
Text Domain: weglotadminbar
// moved to https://wordpress.org/plugins/classic-editor-addon/