Skip to content

Instantly share code, notes, and snippets.

View brichards's full-sized avatar

Brian Richards brichards

View GitHub Profile
@brichards
brichards / wpinstall.sh
Created February 7, 2022 16:26
A shell function to create a directory, install WordPress, configure SSL via Laravel Valet, an launch the site in Chrome
# Install a new WP site.
# Usage: wpinstall <sitename>
function wpinstall() {
# Make the directory in your local web root
mkdir ~/Sites/www/$@;
cd ~/Sites/www/$@;
# Download, config, and install WordPress using <sitename> for the database, URL, and site title
# Note: You'll need to configure your wp-cli defaults for core config and core install in a wp-cli.yml file
wp core download;
@brichards
brichards / country-list.php
Created November 1, 2021 19:46
PHP multi-dimensional array of 2-letter country codes (ISO 3166-1 alpha-2) and their corresponding english name, 3-letter country code (3166-1 alpha-3), and currency.
// Data courtesy http://country.io/data/
$countries = [
'AD' => [ 'name' => 'Andorra', 'alpha2' => 'AD', 'alpha3' => 'AND', 'currency' => 'EUR', ],
'AE' => [ 'name' => 'United Arab Emirates', 'alpha2' => 'AE', 'alpha3' => 'ARE', 'currency' => 'AED', ],
'AF' => [ 'name' => 'Afghanistan', 'alpha2' => 'AF', 'alpha3' => 'AFG', 'currency' => 'AFN', ],
'AG' => [ 'name' => 'Antigua and Barbuda', 'alpha2' => 'AG', 'alpha3' => 'ATG', 'currency' => 'XCD', ],
'AI' => [ 'name' => 'Anguilla', 'alpha2' => 'AI', 'alpha3' => 'AIA', 'currency' => 'XCD', ],
'AL' => [ 'name' => 'Albania', 'alpha2' => 'AL', 'alpha3' => 'ALB', 'currency' => 'ALL', ],
'AM' => [ 'name' => 'Armenia', 'alpha2' => 'AM', 'alpha3' => 'ARM', 'currency' => 'AMD', ],
'AO' => [ 'name' => 'Angola', 'alpha2' => 'AO', 'alpha3' => 'AGO', 'currency' => 'AOA', ],
@brichards
brichards / sb-github-downloads.php
Last active February 16, 2021 17:10
StartBox GitHub Download Generator
<?php
/**
* Plugin Name: StartBox GitHub .zip Generator
* Description: Generates a .zip download for StartBox from GitHub Master.
*
* @props Konstantin Kovshenin (@kovshenin) for sharing his work used on underscores.me (http://code.svn.wordpress.org/underscoresme/plugins/underscoresme-generator/underscoresme-generator.php)
*/
class SB_Download_Generator {
@brichards
brichards / customizer.css
Created February 28, 2020 15:15
Custom CSS for WPBlockTalk.com
h3:before {
display: inline-block;
margin-left: -45px;
padding-right: 45px;
width: 30px;
height: 30px;
background: url('https://cldup.com/_NaTHCOsGQ.svg') no-repeat;
content: '';
}
@brichards
brichards / comments-page.php
Created August 7, 2019 20:13
Plugin to make WordPress comments available at <post_url>/comments/.
<?php
/**
* Plugin Name: Comments Page
* Plugin URI: https://WPSessions.com
* Description: Makes comments for a post accessible at <post_url>/comments/.
* Author: Brian Richards
* Author URI: https://rzen.net
* Text Domain: comments-page
* Domain Path: /languages
* Version: 0.1.0
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*\.(js|css|png|jpe?g|gif|ico)) http://example.com/$1 [NC,P,L]
</IfModule>
@brichards
brichards / rewrites-1.php
Created February 28, 2016 23:25
In all of the below cases permalinks have been flushed. The endpoint works perfectly fine for all scenarios _except_ the home page.
Using only this, hiting ^/bpa/whatever/ serves blog archive instead of static front page.
<?php
/**
* Create url endpoint for BPA
*
* @since 1.0.0
*/
function cfpurl_rewrite_rules() {
@brichards
brichards / functions.php
Created January 3, 2014 14:46
Make all WP oEmbedded videos responsive.
<?php
/**
* Wrap an embedded video with a container for simpler styling.
*
* @since 1.0.0
*
* @param string $output HTML Markup.
* @param string $url oEmbed URL.
@brichards
brichards / gist:7517250
Last active December 28, 2015 14:49 — forked from jaredatch/gist:7517176
=== Almost always running ===
Google Chrome (10 tabs average)
Vagrant (running VirtualBox)
SublimeText 2
iTerm2
Alfred
Dropbox
Skype
Tweetbot
Hipchat
<?php
/**
* Change "Featured Image" to "Achievement Image" throughout media modal.
*
* @since 1.3.0
*
* @param array $strings All strings passed to media modal.
* @param object $post Post object.
* @return array Potentially modified strings.
*/