Skip to content

Instantly share code, notes, and snippets.

View bstonedev's full-sized avatar

Brett Stone bstonedev

View GitHub Profile
@jazzsequence
jazzsequence / ps-demo-plugin.php
Created May 24, 2013 23:06
Demonstration plugin for my Introduction to WordPress Plugin Development course for Pluralsight. Download the full source here: http://cl.ly/3u153a2N1v32
<?php
/*
Plugin Name: Pluralsight plugin development demo
Description: This is a demonstration plugin for the Introduction to WordPress Plugin Development course on Pluralsight.
Author: Chris Reynolds
Version: 1.0
*/
function ps_plugindev_options_page() {
?>
@rxaviers
rxaviers / gist:7360908
Last active July 7, 2024 09:52
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@bateller
bateller / gist:154c6e5d1f6e0e53e527
Last active July 1, 2020 23:11 — forked from boucher/gist:1750375
Stripe Example (Works with v2 of Stripe-PHP)
<?php
// Edited boucher/gist:1750375 to work with stripe-php v2
require 'stripe-php/init.php';
if ($_POST) {
\Stripe\Stripe::setApiKey("YOUR-API-KEY");
$error = '';
$success = '';
try {
if (!isset($_POST['stripeToken']))
throw new Exception("The Stripe Token was not generated correctly");
@oliyh
oliyh / image-url-to-data-uri.js
Created November 7, 2015 22:17
Convert an image url to a data URI without canvas
// hard won knowledge from http://stackoverflow.com/questions/20035615/using-raw-image-data-from-ajax-request-for-data-uri
var xmlHTTP = xhr.XMLHttpRequest();
xmlHTTP.open('GET', url, true);
xmlHTTP.responseType = 'arraybuffer';
xmlHTTP.onload = function(e) {
var arr = new Uint8Array(this.response);
var raw = String.fromCharCode.apply(null,arr);
var b64 = base64.encode(raw);
var dataURL="data:image/png;base64," + b64;
};
@juanfra
juanfra / editor-style-color.php
Created February 27, 2016 14:43
Add the editor style font and color.
<?php
//* Do NOT include the opening php tag
if ( ! function_exists( 'nice_add_editor_custom_styles' ) ) :
add_action( 'after_wp_tiny_mce', 'nice_add_editor_custom_styles' );
/**
* Make sure custom styles are correctly applied to TinyMCE editor.
*
* We use jQuery to wait for the document to be ready, and then we rely on a
* little timeout to ensure TinyMCE is completely loaded before applying styles
<?php
// set some checkout fields to empty
add_filter('woocommerce_checkout_get_value','woo_ongkir_checkout_get_value', 10, 2);
function woo_ongkir_checkout_get_value($default, $field)
{
$empty_fields = array(
'billing_postcode',
'billing_state',
'billing_city',
@jcipriano
jcipriano / upload-async.js
Created September 30, 2016 18:59
Twitter Media Upload Async
var request = require('request');
var fs = require('fs');
var MEDIA_ENDPOINT_URL = 'https://upload.twitter.com/1.1/media/upload.json'
var POST_TWEET_URL = 'https://api.twitter.com/1.1/statuses/update.json'
var OAUTH = {
consumer_key: '',
consumer_secret: '',
@Bobz-zg
Bobz-zg / woo-checkout.php
Last active April 12, 2023 01:41
Pre-populate Woocommerce checkout fields
<?php
/**
* Pre-populate Woocommerce checkout fields
* Note that this filter populates shipping_ and billing_ fields with a different meta field eg 'first_name'
*/
add_filter('woocommerce_checkout_get_value', function($input, $key ) {
global $current_user;
switch ($key) :
@alirezas
alirezas / fade.js
Created February 13, 2017 10:54
fadeIn & fadeOut in vanilla js
function fadeOut(el){
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= .1) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
})();
@helgatheviking
helgatheviking / shortcodes.php
Last active October 11, 2022 21:46
WooCommerce display a single product add to cart form with [add_to_cart_form]
/**
* NB: updated version available here: https://github.com/helgatheviking/add-to-cart-form-shortcode
*/
/**
* Add [add_to_cart_form] shortcode that display a single product add to cart form
* Supports id and sku attributes [add_to_cart_form id=99] or [add_to_cart_form sku=123ABC]
* Essentially a duplicate of the [product_page]
* but replacing wc_get_template_part( 'content', 'single-product' ); with woocommerce_template_single_add_to_cart()
*