Skip to content

Instantly share code, notes, and snippets.

View GaryJones's full-sized avatar

Gary Jones GaryJones

View GitHub Profile
<?php
/**
* Plugin Name: Day-of-the-Month Filter
* Description: Adds a day-of-the-month filter to the posts list table in wp-admin.
* Version: 1.0.0
* Author: Gary Jones
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
@GaryJones
GaryJones / strip-image-meta-data-on-upload.php
Created November 3, 2020 11:09
WordPress: Strip image meta data (except ICC profile) on file upload
<?php
add_filter( 'wp_handle_upload', 'foo_strip_metadata_from_images_on_upload' );
/**
* Overwrite the uploaded image with a new version that has no metadata.
*
* @param array $upload Array containing:
* - file: The path to the image file.
* - url: The URL to the image.
* - type: The MIME type of the image.
--- /var/folders/5h/n5kgg5w13h77n1ffpd4hm2800000gn/T/rPo5nh_superfish.js 2018-10-05 10:50:58.000000000 +0100
+++ /Users/gary/Local Sites/genesis/app/public/wp-content/themes/genesis/lib/js/menu/superfish.js 2018-10-05 10:50:59.000000000 +0100
@@ -1,13 +1,13 @@
/*
- * jQuery Superfish Menu Plugin
- * Copyright (c) 2013 Joel Birch
+ * jQuery Superfish Menu Plugin - v1.7.10
+ * Copyright (c) 2018 Joel Birch
*
* Dual licensed under the MIT and GPL licenses:
--- /var/folders/5h/n5kgg5w13h77n1ffpd4hm2800000gn/T/xxXKfj_superfish.js 2018-10-05 10:45:22.000000000 +0100
+++ /Users/gary/Local Sites/genesis/app/public/wp-content/themes/genesis/lib/js/menu/superfish.js 2018-10-05 10:45:23.000000000 +0100
@@ -1,13 +1,13 @@
/*
- * jQuery Superfish Menu Plugin
- * Copyright (c) 2013 Joel Birch
+ * jQuery Superfish Menu Plugin - v1.7.6
+ * Copyright (c) 2015
*
* Dual licensed under the MIT and GPL licenses:
@GaryJones
GaryJones / fix-category-counts.php
Last active August 6, 2018 13:13
Fix WordPress category (or other taxonomy) counts, after incomplete import, etc.
<?php
// Can drop into {yourtheme}/functions.php and then hit the site.
$update_taxonomy = 'category'; // Set to the correct taxonomy.
$get_terms_args = array(
'taxonomy' => $update_taxonomy,
'fields' => 'ids',
'hide_empty' => false,
@GaryJones
GaryJones / fix-comment-counts.php
Created August 1, 2018 13:15
Fix WordPress comment counts (after incomplete import, etc.
<?php
// Can drop code into top of {yourtheme}/functions.php and then hit the site.
// Fix comment counts.
$post_types = ['post']; // Set to the post types to fix.
$post_status = ['publish', 'pending', 'draft']; // Set to the post status to fix.
global $wpdb;
$posts = $wpdb->get_results(
@GaryJones
GaryJones / per-site-user-fields.php
Created July 9, 2018 20:38
WordPress plugin to store custom and built-in user fields on a per-site basis for WP multisite. Good for multilingual setups. Customise to your needs.
<?php
/**
* Per-Site User Fields
*
* @package GaryJones\PerSiteUserfields
* @author Gary Jones
* @copyright 2018 Gary Jones, Gamajo
* @license GPL-2.0-or-later
*
* @wordpress-plugin
@GaryJones
GaryJones / functions.php
Last active March 15, 2019 21:05
Genesis: Remove microdata attributes
<?php
// Copy everything below this line in to your functions.php file.
/**
* Remove microdata attributes from Genesis 2.6.0.
*
* May need adapting for other versions of Genesis.
*
* @author Gary Jones, Gamajo.
@GaryJones
GaryJones / notes.md
Last active October 24, 2023 19:12
Add PHPCS + WPCS to Sublime Text 3

Install PHP_CodeSniffer (PHPCS) via git

You can use the .phar for PHPCS, but it's easier to pull the repo down from git to then choose what version to use.

cd ~
mkdir -p code
cd code
git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs
@GaryJones
GaryJones / functions.php
Created October 11, 2016 23:29
Genesis: Add classes to footer widget areas container, depending on the configured number of footer widget areas.
<?php
add_filter( 'genesis_footer_widget_areas', 'gmj_add_footer_widgets_classes', 10, 2 );
/**
* Add classes to footer widget areas container, depending on the configured number of footer widget areas.
*
* @param string $output Existing footer widget areas container markup.
* @param int $footer_widgets Number of configured footer widget areas.
* @return string Possibly amended markup for footer widget areas container.
*/