Skip to content

Instantly share code, notes, and snippets.

View kilbot's full-sized avatar

Paul Kilmurray kilbot

View GitHub Profile
@kilbot
kilbot / relevanssi.php
Created February 16, 2016 00:01
Remove Relevanssi
// remove relevanssi
remove_filter('posts_request', 'relevanssi_prevent_default_request');
remove_filter('the_posts', 'relevanssi_query');
@kilbot
kilbot / index.html
Last active February 29, 2016 06:14
Repro Safari IndexedDB autoIncrement bug
<body>
<h1>Repro Safari IndexedDB autoIncrement bug</h1>
<div id="logger"></div>
<script>
var dbname = 'time_' + Date.now() + '_';
function log(msg) {
document.getElementById("logger").innerHTML += msg + "<br>";
}
@kilbot
kilbot / snippet.php
Last active June 17, 2016 04:23
Change default order filters to Pending & Processing
/**
* Change default filter of orders in WP admin
* add this to your functions.php file
*/
add_action( 'admin_menu', 'change_default_order_filter', 99 );
function change_default_order_filter() {
global $submenu;
if (isset($submenu['woocommerce'])) {
$submenu['woocommerce'][1][2] = 'edit.php?post_type=shop_order&shop_order_status=pending,processing';
}
@kilbot
kilbot / functions.php
Last active July 1, 2016 02:56
Adding product meta during checkout
add_action('woocommerce_order_add_product', 'my_custom_product_meta');
function my_custom_product_meta($id, $item_id, $product) {
wc_add_order_item_meta($item_id, 'serial', $product->get_sku());
}
<?php
$conn = new mysqli($WORDPRESS_DB_HOST, $WORDPRESS_DB_USER, $WORDPRESS_DB_PASSWORD);
if(!mysqli_select_db($conn , $WORDPRESS_TESTS_DB_NAME)){
$sql = "CREATE DATABASE $WORDPRESS_TESTS_DB_NAME";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}
@kilbot
kilbot / functions.php
Created September 9, 2016 10:34
Allow customer edit on WordPress multisite
<?php
// change the CASHIER_ID, and
// add to your functions.php file
add_filter('map_meta_cap', 'wc_pos_map_meta_cap', 10, 3);
function wc_pos_map_meta_cap($caps, $cap, $user_id){
if(is_pos() && $cap == 'edit_users' && $user_id === CASHIER_ID){
$caps = array('edit_users');
@kilbot
kilbot / functions.php
Created September 9, 2016 11:08
Filtering the translations in WooCommerce POS
<?php
// add this to your functions.php file
add_filter('woocommerce_pos_i18n', 'my_custom_woocommerce_pos_i18n');
function my_custom_woocommerce_pos_i18n(array $translations){
$translations['buttons']['shipping'] = 'Livraison';
return $translations;
}
@kilbot
kilbot / template.html
Last active October 27, 2016 08:51
add item price column to receipt template
<tr>
<td class="product">
{{name}}
{{#with meta}}
<dl class="meta">
{{#each []}}
<dt>{{label}}:</dt>
<dd>{{value}}</dd>
{{/each}}
</dl>
@kilbot
kilbot / template-stock-report.php
Created November 1, 2016 18:16 — forked from mikejolley/template-stock-report.php
WooCommerce - Stock Report. A template page snippet to (if you are logged in as admin) output a list of products/stock (which you are managing stock for) ready for printing.
<?php
/*
Template Name: Stock Report :)
*/
if (!is_user_logged_in() || !current_user_can('manage_options')) wp_die('This page is private.');
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
@kilbot
kilbot / test.html
Created November 19, 2016 16:57
Multiple Class Inheritance In Backbone Collections
<!DOCTYPE html>
<html>
<head>
<title>Multiple Class Inheritance In Backbone Collections</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js"></script>
</head>
<body>