Skip to content

Instantly share code, notes, and snippets.

Andrew Killen andykillen

Block or report user

Report or block andykillen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View user-roles-plugin.php
<?php
/*
Plugin Name: New User Roles
Plugin URI: https://github.com/andykillen
Description: Adds additional role(s)
Version: 1.0
Author: Andrew Killen
*/
function new_user_roles_plugin_activation() {
@andykillen
andykillen / ClearSwiftCacheCommentApproved.php
Last active Dec 1, 2018
PSR-0 style class with static methods to delete the SWIFT caches on comment approval.
View ClearSwiftCacheCommentApproved.php
<?php
/**
* PSR-0 style class with static methods to delete the SWIFT caches on comment approval.
*
* To make this PSR-4 add a namespace, and prefix Swift_Performance_Cache with a \
* I think its much better that way and saves the much larger Class name.
*
* I've included the init at the bottom, but normally I would have that in a place with all
* other calls so that they are easily visible, like the functions.php
*
@andykillen
andykillen / enabled_modules.txt
Created Apr 3, 2018
list of enabled modules
View enabled_modules.txt
externalauth
ctools
cleantalk
contribute
config_filter
action
automated_cron
block
breakpoint
ckeditor
@andykillen
andykillen / page-facebookimage.php
Created Jan 28, 2018
Show an image to facebook, but show a full page to users
View page-facebookimage.php
<?php
/**
* Template Name: Facebook sees the image
*
**/
/**
* Force no caching, just in case you have some fancy varnish, load balancer
* or other things
**/
@andykillen
andykillen / page-quizredirect.php
Created Jan 28, 2018
WordPress page template, redirect to Quiz url if not facebook.
View page-quizredirect.php
<?php
/**
* Template Name: Facebook quiz redirect
*
**/
function check_if_facebook(){
/**
* this function checks if the current thing accessing the site is a facebook
* bot or not.
@andykillen
andykillen / .gitignore
Created Feb 9, 2017
my standard gitignore for WP
View .gitignore
/* ignore netbeans */
/nbproject/private/
/nbproject/
/* ignore WP core and misc for wordpress on */
wp-content/blogs.dir/
wp-content/upgrade/
wp-content/backup-db/
wp-content/advanced-cache.php
wp-content/wp-cache-config.php
@andykillen
andykillen / resize-images-to-1920px-wide.sh
Created Dec 16, 2016
Run this script in the wp-content/uploads directory, first making sure you have installed jpegoptim and pngcrush. change 1920> to 3.840> if you worry about @2x retina images
View resize-images-to-1920px-wide.sh
#!/bin/bash
for f in $(find . -name '*.jpg' -or -name '*.JPG' -or -name '*.JPEG' -or -name '*.jpeg' -or -name '*.png'); do
convert "$f" -resize "1920>" "$f";
@andykillen
andykillen / create-wget-for-bash.php
Last active Dec 15, 2016
Checks through a db looking for posts table and creates a text file with all the wget commands to retrieve the images of the site. To run just load the php file, enter the form fields and then after it has created the txt file run is 'bash wp_posts.txt' at the terminal.
View create-wget-for-bash.php
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Search for all images on WordPress and download to directory via WGET task list</title>
</head>
<body>
<h1>Search for all images on WordPress and download to directory via WGET task list</h1>
<?php
View gulp.js
var gulp = require('gulp');
var concat = require('gulp-concat');
// var minifyCSS = require('gulp-minify-css');
var minify = require("gulp-minify");
var cleanCSS = require('gulp-clean-css');
var rename = require("gulp-rename");
var autoprefixer = require('gulp-autoprefixer');
var sass = require('gulp-sass');
gulp.task('styles', function() {
@andykillen
andykillen / always-have-a-default-first.js
Created Jun 18, 2016
Always have a default, and always check before trying to use that the selector responds with something
View always-have-a-default-first.js
// you can do this
$('.class-to-find').each(function(index){
outputValue = $(this).text();
});
// but it will fail badly if there is nothing found by $('class-to-find').
//better to do
outputValue = ''; // set a default value
if($('.class-to-find').length){ // make sure that there is something to loop
$('.class-to-find').each(function(index){ // do the loop
You can’t perform that action at this time.