Skip to content

Instantly share code, notes, and snippets.

View craigiswayne's full-sized avatar

Craig Wayne craigiswayne

View GitHub Profile
@craigiswayne
craigiswayne / CW_Comments_Recaptcha.php
Created June 8, 2017 10:49
WordPress Comments Recaptcha
<?php
/**
* Class CWP_Comments_Recaptcha
* Allows you to add recaptcha to WordPress Comments
*/
class CW_Comments_Recaptcha {
const js_url = 'https://www.google.com/recaptcha/api.js';
@craigiswayne
craigiswayne / wp-plugin-audit.js
Created June 8, 2017 10:58
WordPress Plugin Audit Snippet (Markdown)
var $ = jQuery;
var plugin_rows = $("table.wp-list-table.plugins tbody tr").not(".plugin-update-tr");
var plugins = [];
var markdown = "";
if( $(plugin_rows).length > 0 ){
markdown = "| Name | Version | Status |";
markdown += "\n";
markdown += "| --- | --- | --- |";
@craigiswayne
craigiswayne / README.md
Created June 16, 2017 17:18
Create an Off Canvas Menu with WordPress and UIKIT

Create an Off Canvas Menu with WordPress and UIKIT

Add the following to your functions.php file

add_action ( 'init', function(){
  $menu_locations = [
    'off_canvas' => __( 'Off Canvas' )
  ];
  register_nav_menus( $menu_locations );
@craigiswayne
craigiswayne / snippet.js
Created July 15, 2017 12:16
WordPress Javascript REST API Example
var collection = new wp.api.collections.Posts();
collection.fetch().done(function(response) {
console.log(response);
console.log('| ID | Author | Date | Title |');
console.log('|-------|--------|---------------------|--------|');
for ( var i = 0; i < response.length; i++) {
@craigiswayne
craigiswayne / find_woo_options_used.sh
Last active October 17, 2017 10:17
Find all woo_options used in directory files
grep -R -E "(?:woo_options\['(.*)'\])" ./ --include='*.php' -ohw
@craigiswayne
craigiswayne / pi_ngrok.sh
Last active December 13, 2017 22:03
Ngrok on Raspberry PI
###########################
# NGROK DOCS:
# https://ngrok.com/docs
###########################
cd ~/
wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip
unzip ngrok-stable-linux-arm.zip
sudo mv ngrok /usr/local/bin/
ngrok http 80
@craigiswayne
craigiswayne / extensibility.sh
Last active July 12, 2018 23:17
How Extensible is a WordPress Plugin
# Find all do_action's and add_action's
grep -En "(add|do)_action\(" . -R --context=2 --include="*.php"
# Find all apply_filter's and add_filter's
grep -En "(apply|add)_filters?\(" . -R --context=2 --include="*.php"
@craigiswayne
craigiswayne / setup.sh
Last active May 20, 2018 09:43
Raspberry PI 3, OSMC and Plex Setup
###
# References https://craigiswayne.wordpress.com/2018/01/20/my-media-centre/
###
####
# Variables
####
PI_IP=192.168.8.112;
PI_USERNAME=osmc;
@craigiswayne
craigiswayne / README.md
Created May 22, 2018 09:49
Nginx Verbose Access Log Format

The snippet below outputs a verbose version of the nginx access log

To use it, simply copy the contents of verbose-access.conf and paste it into your http block.

NB:

make sure to remove / comment out any existing access_log definitions such as access_log /var/log/nginx/access.log;

Example output:

@craigiswayne
craigiswayne / follow_url.sh
Created May 29, 2018 07:40
Follow Redirects on URL
URL=www.google.com
curl -sILk $URL;