Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Hardie ChrisHardie

View GitHub Profile
@ChrisHardie
ChrisHardie / keybase.md
Created Jul 19, 2014
Keybase identity proof
View keybase.md

Keybase proof

I hereby claim:

  • I am ChrisHardie on github.
  • I am chrishardie (https://keybase.io/chrishardie) on keybase.
  • I have a public key whose fingerprint is 20C3 E523 5B67 AB60 9F3C 1024 FFB4 0D5A 25D9 BA70

To claim this, I am signing this object:

@ChrisHardie
ChrisHardie / jetpack-test.php
Created Jan 23, 2018 — forked from delputnam/jetpack-test.php
A simple WordPress plugin to allow testing of Jetpack's Related Posts module
View jetpack-test.php
<?php
/**
* @package Jetpack_Test
* @version 1.0
*/
/*
Plugin Name: Jetpack Test
Description: Allows certain Jetpack modules that would otherwise require a connection to WordPress.com to be run in a local development environment.
Author: Del Putnam
@ChrisHardie
ChrisHardie / class-jch-portfolio-postmeta.php
Created Jul 5, 2018
Extend the Jetpack Portfolio CPT to allow specifying a project URL that can be linked to instead of the portfolio item itself
View class-jch-portfolio-postmeta.php
<?php
/**
* Class JCH_Portfolio_Postmeta
* Create meta boxes, post meta fields and archive link filters for portfolio items
* With some help from https://gist.github.com/carlodaniele/121841f92956c3304436
*/
class JCH_Portfolio_Postmeta {
@ChrisHardie
ChrisHardie / functions.php
Last active Aug 21, 2018
Example function to load plugins within wp-content/themes/mytheme/plugins/
View functions.php
/**
* Add in-theme plugins
*/
function my_theme_plugins() {
$plugins_to_include = array(
'wordpress-fieldmanager/fieldmanager.php',
);
if ( count( $plugins_to_include ) ) {
@ChrisHardie
ChrisHardie / functions.php
Created Sep 12, 2018
Override Jetpack development mode to activate modules for testing in WordPress
View functions.php
/**
* Modify Jetpack module properties for testing/development
*
* @param array $mod Module to look at modifying the properties of.
* @return boolean
*/
function jp_module_override( $mod ) {
switch ( $mod['name'] ) {
case 'Related posts':
$mod['requires_connection'] = false;
@ChrisHardie
ChrisHardie / functions.php
Created Sep 24, 2018
WordPress one-time role/capability fix for Yoast SEO on Multisite
View functions.php
if ( ! function_exists( 'my_add_seo_caps' ) ) {
function dnc_add_seo_caps() {
// Get admin role
$role = get_role( 'administrator' );
// Add YOAST SEO Roles
$role->add_cap( 'wpseo_manage_options' );
$role->add_cap( 'wpseo_edit_advanced_metadata' );
$role->add_cap( 'wpseo_manage_redirects' );
$role->add_cap( 'wpseo_bulk_edit' );
}
@ChrisHardie
ChrisHardie / rss.pl
Created Jan 10, 2019
Generate an RSS feed in Perl
View rss.pl
#!/usr/bin/perl
use XML::RSS;
use strict;
my @event_array = <SQL MAGIC GOES HERE>;
my $rss = new XML::RSS;
$rss->channel( title => 'Your Title Here', link => 'https://...',
description => 'Your description here.' );
@ChrisHardie
ChrisHardie / get-facebook-events.php
Created Oct 8, 2019
Proof of concept, retrieve publicly-available Facebook page event data.
View get-facebook-events.php
<?php
/**
* Proof of concept, retrieve publicly-available Facebook page event data.
* Chris Hardie <chris@chrishardie.com>
*
* To use, first add Guzzle as a dependency:
* $ commposer require guzzlehttp/guzzle
*
*/
@ChrisHardie
ChrisHardie / check-for-results.php
Created Nov 5, 2019
A PHP script to check for results in the Wayne County, Indiana 2019 Mayoral Election
View check-for-results.php
<?php
require __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/config.php';
$output_messages = array();
$wayneco_results_html = file_get_contents( WAYNECO_RESULTS_URL );
$state_results_html = file_get_contents( STATE_RESULTS_URL );
@ChrisHardie
ChrisHardie / class-api-routes.php
Created Feb 18, 2020
Flickr-to-WordPress: a class defining a REST API endpoint to determine the local WordPress equivalent of an imported Flickr photo
View class-api-routes.php
<?php
/**
* Class JCHPhotos_Plugin_API_Routes
*
* Handles API endpoints for looking up Flickr-to-WordPres translation stuff.
*/
class JCHPhotos_Plugin_API_Routes {