Skip to content

Instantly share code, notes, and snippets.

View swak's full-sized avatar

Shaun Wakashige swak

View GitHub Profile
@mikejolley
mikejolley / template-stock-report.php
Created December 5, 2011 20:18
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" />
@rubensayshi
rubensayshi / gist:4208247
Created December 4, 2012 20:17
GW2Spidy example
<?php
ini_set('max_execution_time', 0);
class GW2SpidyDataset {
protected $data;
public function getItemById($id) {
if (!$this->data) {
$this->getData();
@kloon
kloon / gist:4228021
Created December 6, 2012 20:25
WooCommerce variations custom field
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'variable_fields_process', 10, 1 );
function variable_fields( $loop, $variation_data ) {
?>
<tr>
@kloon
kloon / functions.php
Last active September 15, 2022 11:04
WooCommerce Dropdown Product Quantity, fully compatible with Min/Max quantities extension
<?php
// Place the following code in your theme's functions.php file
// override the quantity input with a dropdown
function woocommerce_quantity_input() {
global $product;
$defaults = array(
'input_name' => 'quantity',
'input_value' => '1',
'max_value' => apply_filters( 'woocommerce_quantity_input_max', '', $product ),
@aahan
aahan / WordPress Custom Global Variables.md
Last active March 28, 2024 19:26
Creating and using custom global variables in wordpress.

First create global variables (in functions.php or as a mu-plugin):

<?php

/*
 * CUSTOM GLOBAL VARIABLES
 */
function wtnerd_global_vars() {
@manjeshpv
manjeshpv / passport.js
Last active February 29, 2024 15:11
Passport.js using MySQL for Authentication with Express
// config/passport.js
// load all the things we need
var LocalStrategy = require('passport-local').Strategy;
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
@mikesigs
mikesigs / angular-directive-priority.md
Last active November 17, 2022 12:49 — forked from awerlang/angular-directives
Angular Directive Priority - Quick Reference

##Angular Directive Priority - Quick Reference

When there are multiple directives defined on a single DOM element, sometimes it is necessary to specify the order in which the directives are applied. The priority is used to sort the directives before their compile functions get called. Priority is defined as a number. Directives with greater numerical priority are compiled first. Pre-link functions are also run in priority order, but post-link functions are run in reverse order. The order of directives with the same priority is undefined. The default priority is 0.

For a brief description of each directive, click here.

Directive | Priority | Terminal | Creates new scope | Can be used as multiElement ---------- | :---------: | :---------: | :---------------

Some of the Redis best practices content has moved

This content from this markdown file has moved a new, happier home where it can serve more people. Please check it out : https://docs.microsoft.com/azure/azure-cache-for-redis/cache-best-practices.

NOTE: Client specific guidance listed below is still valid and should still be considered. I will update this document once all content has been moved.

@jrrodjr
jrrodjr / sketch_addLibraryFileFromPlugin.js
Last active July 21, 2018 09:42
Sketch : Install a file as a library from the plugin resources
function addLibraryFileFromPlugin(context) {
var sketch = context.api();
var libSourceFile = "libraries/myLibrary.sketch"; // The file with the symbols for your library; should located in the plugin's resources folder
var libSourcePath = context.plugin.urlForResourceNamed(libSourceFile).path();
if(libSourcePath) {
var libURL = NSURL.fileURLWithPath(libSourcePath);
var libPaneIdentifier = MSAssetLibrariesPreferencePane.identifier();
var libPane = MSPreferencesController.sharedController().preferencePanes().objectForKey(libPaneIdentifier);
// Set a minimum amount of oder based on shipping zone before checking out
add_action( 'woocommerce_check_cart_items', 'cw_min_num_products' );
// Only run in the Cart or Checkout pages
function cw_min_num_products() {
if( is_cart() || is_checkout() ) {
global $woocommerce;