Skip to content

Instantly share code, notes, and snippets.

View gschoppe's full-sized avatar

Greg Schoppe gschoppe

View GitHub Profile
@gschoppe
gschoppe / mb_string_shim.php
Last active November 16, 2017 00:58
Shim for servers that do not support mb_string functions. modified from Patchwork. Usage: if(!function_exists('mb_strtolower')) { require_once('mb_string_shim.php'); }
<?php
/*
* Copyright (C) 2013 Nicolas Grekas - p@tchwork.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the (at your option):
* Apache License v2.0 (http://apache.org/licenses/LICENSE-2.0.txt), or
* GNU General Public License v2.0 (http://gnu.org/licenses/gpl-2.0.txt).
*/
@gschoppe
gschoppe / upcoming-drafts-alert.php
Created December 22, 2017 15:31
Sends regular reminder emails to all users with draft posts scheduled for less than X days in the future. Usage: 1. Install and activate WP Utility Script Runner (https://wordpress.org/plugins/wp-utility-script-runner/) 2. Create a "utilities" subfolder in your theme directory 3. Place this file in the utilities folder 4. Go to Tools->Utility Sc…
<?php if(!defined('ABSPATH')) { die(); } // This line ensures that the script is not run directly
/**
* Utility Name: Upcoming Drafts Alert
* Description: Sends an email to blog authors with upcoming or overdue posts
* Author: Greg Schoppe
* Author URI: https://gschoppe.com
* Supports: input, cron
* Version: 1.0.0
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@gschoppe
gschoppe / wp-jslabify-titles.php
Last active March 22, 2018 14:28
add to functions.php to allow WP jSlabify to slab post titles
<?php
add_filter( 'the_title', 'wp_jslabify_title', 10, 2 );
function wp_jslabify_title( $title, $id=0 ) {
$slabbed_post_types = array(
'single' => array( 'post', 'page' ),
'archive' => array(),
'search' => array()
);
$theme = 'ultra';
@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 / 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 / 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/
@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 / cat-like-custom-taxonomy.php
Created February 28, 2016 01:07
Use category (checkbox-based) interface with non-hierarchical custom taxonomies
<?php
// Event taxonomies
add_action( 'init', function() {
$labels = array(
'name' => _x( 'Terms', 'taxonomy general name' ),
'singular_name' => _x( 'Term', 'taxonomy singular name' ),
);
register_taxonomy( 'taxonomy_name', array( 'post' ), array(
'hierarchical' => false,
function DB(projectID) {
this.projectID = projectID;
this.types = {
'INT64' : "INT64",
'NUMERIC' : "NUMERIC",
'BIGNUMERIC': "BIGNUMERIC",
'FLOAT64' : "FLOAT64",
'BOOL' : "BOOL",
'STRING' : "STRING",