Skip to content

Instantly share code, notes, and snippets.

View gbot's full-sized avatar

GB gbot

View GitHub Profile
@robin-scott
robin-scott / htaccess
Created October 19, 2018 08:37
Deny access to wp-admin BUT allow ajax to be used in WordPress
// Add this to an .htaccess file at the top of the wp-admin directory to lock down this section of your site to only trusted IP addresses - BUT still allow ajax access
// By Robin Scott of Silicon Dales - details here: https://silicondales.com/tutorials/wordpress/lock-out-all-traffic-except-your-ip-from-login-admin/
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
</Files>
Order Deny,Allow
Deny from all
@gbot
gbot / wp_offload_media_db_migrate.json
Last active March 20, 2023 20:24
Migrate a WordPress database so that existing media items are served from Amazon S3 or CloudFront. Requires the WP Offload S3 Lite plugin.
{
"use_https": "",
"purge_amazonS3_info": ""
}
@vegaskev
vegaskev / functions.php
Created July 20, 2018 22:05
Change Gravity Forms Spinner to CSS Spinner
// Changes Gravity Forms Ajax Spinner (next, back, submit) to a transparent image
// this allows you to target the css and create a pure css spinner like the one used below in the style.css file of this gist.
add_filter( 'gform_ajax_spinner_url', 'spinner_url', 10, 2 );
function spinner_url( $image_src, $form ) {
return 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7'; // relative to you theme images folder
}
#!/bin/bash
# variables
LOGFILE="/var/log/nginx/access.log"
LOGFILE_GZ="/var/log/nginx/access.log.*"
RESPONSE_CODE="200"
# functions
filters(){
grep $RESPONSE_CODE \
@joshisa
joshisa / URL Parsing
Created February 3, 2017 02:27
Parsing of URLs using bash sh scripting
#!/bin/bash
# Referenced and tweaked from http://stackoverflow.com/questions/6174220/parse-url-in-shell-script#6174447
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol
url="$(echo ${1/$proto/})"
# extract the user (if any)
userpass="$(echo $url | grep @ | cut -d@ -f1)"
pass="$(echo $userpass | grep : | cut -d: -f2)"
if [ -n "$pass" ]; then
@pelmered
pelmered / wpfcwc.conf
Created March 27, 2015 08:56
EasyEngine WooCommerce config with FastCGI Cache
#
set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
<?php
/**
* A class filled with functions that will never go away upon theme deactivation
*
* @package WordPress
* @subpackage GRD
* @version 0.1.0
*/
class GRD_Functions {
@gregrickaby
gregrickaby / grd_functions.php
Last active April 10, 2018 02:38
A "must use" plugin to help save theme-agnostic functions
<?php
/**
* Must-Use Functions
*
* A class filled with functions that will never go away upon theme deactivation.
*
* @package WordPress
* @subpackage GRD
*/
class GRD_Functions {
@louy
louy / .htaccess
Created July 25, 2013 22:31
Apache .htaccess geographical redirect based on CloudFlare's geo-ip headers
# add as many as you need...
SetEnvIf CF-IPCountry SY RedirectSubdomain=syria
SetEnvIf CF-IPCountry AE RedirectSubdomain=uae
SetEnvIf CF-IPCountry EG RedirectSubdomain=egypt
# Only redirect if Host is not a subdomain
SetEnvIfNoCase Host ^.+\.example\.com$ !RedirectSubdomain
# Only redirect if cookie "noredirect" doesn't exist
SetEnvIfNoCase ^Cookie$ noredirect=true !RedirectSubdomain
@luetkemj
luetkemj / wp-query-ref.php
Last active April 25, 2024 09:37
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/