Skip to content

Instantly share code, notes, and snippets.

View andykillen's full-sized avatar

Andrew Killen andykillen

View GitHub Profile
<?php
/**
* Plugin Name: Servebolt Hide Admin Menus
* Description: Hides the admin menus for role(s) that they are not wanted for.
* Author: Servebolt
* Author URI: https://servebolt.com
* Version: 1.0
* @author Servebolt
* @package Servebolt Hide Admin Menus
**/
@andykillen
andykillen / feed-update-pricing.php
Created September 5, 2023 14:34
Faster updates
<?php
global $wpdb;
$query = $wpdb->prepare("SELECT post_id, table1.meta_value as sku, table2.meta_value as price ".
"FROM {$wpdb->postmeta} as table1 ".
"JOIN {$wpdb->postmeta} as table2 USING (post_id) ".
"WHERE ".
"table1.meta_key = '_sku' AND ".
"table2.meta_key = '_price' ".
@andykillen
andykillen / tax_query.php
Last active September 6, 2023 09:41
taxonomy queries
<?php
$args = [
'post_type' => 'product',
'posts_per_page' => 24,
'post_status' => 'publish',
'tax_query' => [
'relation' => 'AND',
[
'taxonomy' => 'pa_brand',
<?php
/**
* copyrights andrew killen 2017
*
* Attribution-ShareAlike 4.0 International.
**/
/**
* This will get the contents from the db about the current values, optionally if you have setup
<?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 December 1, 2018 13:41
PSR-0 style class with static methods to delete the SWIFT caches on comment approval.
<?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 April 3, 2018 07:19
list of enabled modules
externalauth
ctools
cleantalk
contribute
config_filter
action
automated_cron
block
breakpoint
ckeditor
@andykillen
andykillen / page-facebookimage.php
Created January 28, 2018 19:23
Show an image to facebook, but show a full page to users
<?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 January 28, 2018 18:59
WordPress page template, redirect to Quiz url if not facebook.
<?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 February 9, 2017 15:56
my standard gitignore for WP
/* 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