Skip to content

Instantly share code, notes, and snippets.

@ethicka
ethicka / localhost-ssl.md
Last active April 12, 2024 12:26 — forked from jonathantneal/README.md
Local virtualhost SSL websites on Mac OS Sierra

Local virtualhost SSL websites on Mac OS Sierra

These instructions will guide you through the process of setting up a wildcard SSL for your local virtualhosts for offline development. Most importantly, this configuration will give you the happy, green lock in Chrome.

These instructions have only been tested on Mac OS Sierra using the pre-installed Apache and PHP versions. These instructions also assume you have virtualhosts set up locally already.


Configuring SSL

@ethicka
ethicka / localhost-ssl-certificate.md
Last active February 18, 2024 16:29
Localhost SSL Certificate on Mac OS

🚨 2020 Update: I recommend using mkcert to generate local certificates. You can do everything below by just running the commands brew install mkcert and mkcert -install. Keep it simple!


This gives you that beautiful green lock in Chrome. I'm assuming you're putting your SSL documents in /etc/ssl, but you can put them anywhere and replace the references in the following commands. Tested successfully on Mac OS Sierra and High Sierra.

Set up localhost.conf

sudo nano /etc/ssl/localhost/localhost.conf

@ethicka
ethicka / wp-start.sh
Last active December 27, 2023 07:10
WordPress Installation with the Roots/Sage Framework and VirtualHost Creation
#!/bin/bash -e
##
# WordPress Installation and VirtualHost Creation
#
# Description: Installs a WordPress website in the ~/Sites folder, creates a homepage,
# cleans up the WP install a bit, deletes the akismet and hello dolly plugins, creates the permalinks,
# clones the roots/sage theme framework to the theme folder, deletes all the other WP default themes,
# installs/runs npm and bower and runs gulp to create the initial assets, adds a custom gitignore file
# to /wp-content, installs the roots/soil plugin, creates a git repo in wp-content, saves the WordPress
@ethicka
ethicka / remove-facet-count.php
Created February 3, 2020 20:27
FacetWP: Remove Facet Count
<?php
add_filter('facetwp_facet_html', function ($output, $params) {
if ('dropdown' == $params['facet']['type']) {
$output = preg_replace("/( \([0-9]+\))/m", '', $output);
}
return $output;
}, 10, 2);
@ethicka
ethicka / facetwp_pager_html.php
Last active May 20, 2021 11:01 — forked from MWDelaney/facetwp.php
FacetWP Bootstrap 4 Pagination (facetwp_pager_html)
<?php
/**
* FacetWP Pager Bootstrap 4 Pagination
* @source https://gist.github.com/MWDelaney/ce9e523b3f1bdf57b3180c9b24b73170
* @source https://fellowtuts.com/bootstrap/wordpress-pagination-bootstrap-4-style/
*/
add_filter('facetwp_pager_html', function ($output, $params) {
$range = 2; // +/- pages from the current page
$showitems = ($range * 2) + 1;
$page = $params['page'];
@ethicka
ethicka / remote-uploads.php
Created February 26, 2021 17:45
Load wp-content/uploads from the remote site
<?php
/**
* Loads media from a remote site when on a local dev environment.
* Eliminates the need to download the uploads directory from the remote site for testing purposes.
* Replace WEBSITE with you domain name.
*/
if ('WEBSITE.local' === $_SERVER['HTTP_HOST']) :
add_filter('upload_dir', function ($uploads) {
$uploads['baseurl'] = 'https:/WEBSITE.com/wp-content/uploads';
@ethicka
ethicka / pdf-to-jpg.sh
Last active October 9, 2020 14:33
Convert a folder of PDFs to JPGs
#!/bin/bash
# Dependencies: vips
# Homebrew: brew install vips
for file in *.pdf
do
# Run vips pdfload for options
# You could add --page=1 to get the second page (from 0) or --dpi=300, etc. to get different quality images
# The variable gets the filename without the extension
vips pdfload ${file%.*}.pdf ${file%.*}.jpg
done
@ethicka
ethicka / sage9-deploybot.md
Last active May 4, 2020 07:24
How to build and deploy a Roots / Sage 9 WordPress theme on Deploybot

Deploying Roots Sage 9 via Deploybot

Sage 9 is the latest and greatest from Roots, but the build process is much more complicated than Sage 8 (i.e. gulp --production and profit). The following took me quite a bit of time to figure out, but is probably not comprehensive. Please comment if you need clarity. I hope it saves you some time!

Build the Container

Deploybot allows you to create your own containers. Go to Settings > Containers > Create a container. Based off the Ubuntu 16.04 container add the following build commands and save as Sage 9:

@ethicka
ethicka / build-comma-separated-string.php
Created April 29, 2020 21:38
Build a comma separated string of one or more strings
<?php
/**
* Build Comma-Separated String
* Won't add a hanging comma if there's only passed value
*/
function comma_separated($array) {
$string = implode(', ', $array);
if (preg_match("/, $/", $string)) { // if it ends in a comma, remove the comma
$string = substr($string, 0, -2);
}
@ethicka
ethicka / build-a-name.php
Created April 29, 2020 21:37
Build a name from a prefix and suffix
<?php
/**
* Build a name
*/
function build_name($prefix, $fname, $lname, $suffix) {
$name = $fname . ' ' . $lname;
if($prefix) $name = $prefix . ' ' . $name;
if($suffix) $name = $name .= $suffix;
return $name;
}