Skip to content

Instantly share code, notes, and snippets.

View ChrisHardie's full-sized avatar

Chris Hardie ChrisHardie

View GitHub Profile
@ChrisHardie
ChrisHardie / jch-flickr-fixer.php
Created February 18, 2020 16:55
Flickr-to-WordPress: a plugin to use a WordPress powered API to find/replace Flickr references in another WordPress site
<?php
/**
* Plugin Name: Flickr Fixer
* Plugin URI: https://chrishardie.com/
* Description: Find/replace Flickr references
* Version: 1.0
* Author: Chris Hardie
* Author URI: https://chrishardie.com/
*/
@ChrisHardie
ChrisHardie / twitter-timeline-to-rss-feed.php
Last active April 6, 2021 10:06
Example PHP script to generate an RSS feed from a user's timeline for tweets that match a certain set of criteria
<?php
/**
* Generate an RSS feed from a Twitter user's timeline
* Chris Hardie <chris@chrishardie.com>
*/
require "/path/to/vendor/autoload.php" ;
use Abraham\TwitterOAuth\TwitterOAuth;
@ChrisHardie
ChrisHardie / storycorps-to-rss.php
Created October 14, 2019 16:41
Example PHP script to generate an RSS feed of a StoryCorps Archives interview search result
<?php
$storycorps_archive_html = file_get_contents( 'https://api.storycorps.me/wp-json/interviews?filter[places]=richmond,indiana' );
$storycorps_archive = json_decode( $storycorps_archive_html, true );
$xml = new SimpleXMLElement('<rss/>');
$xml->addAttribute("version", "2.0");
$channel = $xml->addChild("channel");
@ChrisHardie
ChrisHardie / multisite_attachment_url.php
Created March 18, 2019 01:27
Example WordPress plugin to help simplify attachment URLs on multisite sites with mapped domains
<?php
/**
* Plugin Name: Multisite Domain Mapping Attachment URL Fixes
* Description: Update attachment URLs to use mapped domain and remove mention of "sites" path.
* Author: Chris Hardie
*
* Rewrite attachment URLs (and related srcset URLs) to the non-multisite, mapped domain version if a domain is mapped
* Requires that the related nginx config that maps the non-multisite URL to the multisite URL be in place
**/
add_filter( 'wp_get_attachment_url', 'jch_attachment_url_with_domain_mapping' );
@ChrisHardie
ChrisHardie / instagram-to-rss.php
Created October 14, 2019 16:50
Sample PHP script to scrape an Instagram public profile and generate an RSS feed
<?php
$target_accounts = array(
'bikes_as_transportation',
);
foreach ( $target_accounts as $target_user ) {
$target_user = urlencode( $target_user );
@ChrisHardie
ChrisHardie / deploy-laravel-app.sh
Created February 14, 2022 15:24
Simple Bash script to deploy a Laravel App
#!/bin/bash
version=`php artisan --version`
if [[ ${version} != *"Laravel Framework"* ]]; then
echo "Not a Laravel app, exiting."
exit;
fi
# Turn on maintenance mode