Skip to content

Instantly share code, notes, and snippets.

View ccurtin's full-sized avatar
🤙
makka thangs

Christopher James Curtin ccurtin

🤙
makka thangs
View GitHub Profile
@ccurtin
ccurtin / WP-REST-API--self-served.htaccess
Last active June 20, 2023 03:46
DISMISS PUBLIC ACCESS to WordPress REST API; ONLY ALLOW API ACCESS VIA SAME DOMAIN. ALLOW ADMIN ACCESS FOR ALL THOUGH.... for dynamic IPs... *Ideally*, the Server should be making the requests to the API, not the Client/User. That way, all API access is invalid except from the server. Use CORS and this snippet to block all WP access though.
# - DISMISS PUBLIC ACCESS; ONLY ALLOW API ACCESS VIA OWN DOMAIN
# - ALLOW ADMIN ACESS FOR ALL
#
# This example is in the "public_html/api/" folder where
# the WP API is installed.
#
RewriteEngine On
# If the referer is not its own domain
RewriteCond %{HTTP_REFERER} !^http?://architectura.com [NC]
# Then make it forbidden if not an admin login th
@ccurtin
ccurtin / loop-through-categories.php
Last active October 7, 2017 07:51
Loop through categories for a taxonomy term in WordPress!
<?php
/* Gets all sub-terms of a taxonomy-term and if no more exist, display posts for that term. */
/* This doesn't need an action, should be added to the functions.php file */
function loop_through_cats($term_id){
echo "<ul>";
$args = array(
'hierarchical' => 1,
'hide_empty' => 0,
@ccurtin
ccurtin / force-https-site-and-requests.htaccess
Created March 20, 2017 16:54
Force HTTPS for site and any requested resources
# force site HTTPS
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# force any requested file to HTTPS. CSS, JS, images, etc.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@ccurtin
ccurtin / CSS-gradient-overlay.css
Created March 12, 2017 19:35
Gradient overlay CSS w/ using pseudo element.
div:before {
content: "";
position: absolute;
background: -webkit-linear-gradient(350deg, rgba(49, 27, 146, .8) 35%, rgba(125, 38, 205, .75));
background: linear-gradient(350deg, rgba(49, 27, 146, .8) 35%, rgba(125, 38, 205, .75));
width: 100%;
height: 100%;
top: 0;
left: 0;
right: 0;
@ccurtin
ccurtin / get-wordpress-rest-api-urls-working.md
Last active March 6, 2017 23:27
If WP REST API is not working, you MUST update the `AllowOverride All` Directive in hosting config.
  1. Login via SSH as root user
  2. Navigate to "/usr/local/apache/conf/userdata/std/2/USER_NAME"
  3. Create a new file: directory.conf
  4. Edit that file to update "AllowOverride" directive for the site:
  <Directory "/home/USER_NAME/public_html">
          Options Indexes FollowSymLinks
          AllowOverride All
          Require all granted
 
@ccurtin
ccurtin / password-protect-wp-login.php.htacces
Created March 1, 2017 04:54
Password Protect wp-admin / wp-login.php
<FilesMatch "wp-login.php">
AuthName "Protected Login"
AuthType Basic
AuthUserFile /home/ACCOUNT_NAME/.htpasswds/.htpasswd
AuthGroupFile /dev/null
require valid-user
</FilesMatch>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
@ccurtin
ccurtin / browserSpecificEventNames.js
Created February 27, 2017 00:41
returns prefixed transition and animation events for use in javascript. Checks if Animation exists first, then custom type. ex: element.addEventListener(browserSpecificEventNames("AnimationStart"),function(){console.log("testing")}, false)
function browserSpecificEventNames(type) {
// create test element
var elm = document.createElement('div'),
match = {},
list = {
'WebkitAnimation': 'webkit' + type,
'MozAnimation': 'moz' + type,
'OAnimation': 'o' + type,
'msAnimation': 'MS' + type,
'animation': type,
@ccurtin
ccurtin / upgrade-php-centos-distro.md
Last active December 9, 2016 21:35
Upgrading PHP version in a CentOS distro.
@ccurtin
ccurtin / update-linux-timezone.sh
Last active December 7, 2017 03:39
Update Linux TimeZone
# /etc/localtime is a file. not a dir.
sudo rm /etc/localtime
cp /usr/share/zoneinfo/America/New_York /etc/localtime
@ccurtin
ccurtin / full-site-backup-w-vagrant.sh
Last active October 6, 2016 22:02
Create a backup. Best to place this in `/bin/make_backup` and chmod +x so that users can run the command whenever they want.
#!/bin/bash
GREEN="$(echo -e "\033[32m")"
YELLOW="$(echo -e "\033[33m")"
RESET="$(echo -e "\033[0m")"
BU_NAME=$(hostname)-site-backup-$(date +%Y-%m-%d-%H-%M)
BACKUPS_DIR="/vagrant/www/BACKUPS/$BU_NAME"
# inject date into SQL filenames.
BACKUP_DB="$BU_NAME.sql"
BACKUP_DB_FULL="/vagrat/www/BACKUPS/$BU_NAME/site-backup-$BU_NAME.sql"
BACKUP_ZIP="$BU_NAME.zip"