Skip to content

Instantly share code, notes, and snippets.

@hiphopsmurf
hiphopsmurf / echo-wc-sku.php
Created February 15, 2016 09:36 — forked from bekarice/echo-wc-sku.php
Print WC Product SKU
/**
* Echos the SKU for the product when used on a single product page
* Can optionally pass in the ID to echo the SKU for a product elsewhere
* Use [wc_sku] or [wc_sku id="ID"]
* Tutorial: http://www.skyverge.com/blog/output-woocommerce-sku/
**/
function skyverge_get_product_sku( $atts ) {
global $product;
@hiphopsmurf
hiphopsmurf / woocommerce-disable-paypal-for-subscriptions.php
Created February 14, 2016 01:33 — forked from thenbrent/woocommerce-disable-paypal-for-subscriptions.md
Using WooCommerce and want to disable PayPal for subscription purchases, but still offer it as an option for buying one-off products? Activate this plugin.
<?php
/**
* Plugin Name: WooCommerce Disable PayPal for Subscriptions
* Plugin URI: https://gist.github.com/thenbrent/6641526
* Description: Want to disable PayPal for subscription purchases, but still offer it as an option for buying one-off products? Activate this plugin. It will also disable PayPal for subscription renewal. Requires WooCommerce 2.2 or newer.
* Author: Brent Shepherd
* Author URI: http://find.brentshepherd.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
@hiphopsmurf
hiphopsmurf / gist:d6caabdf76a48a75a320
Created January 6, 2016 22:12 — forked from rjacoby/gist:46f7ceb900f97b0cc8f4
Facebook STOP! console code
__d("Chromedome", ["fbt"], function(a, b, c, d, e, f, g) {
f.start = function(h) {
if (h.off || top !== window ||!/(^|\.)facebook\.com$/.test(document.domain))
return;
var i = h.stop || "Stop!", j = h.text || "This is a browser feature intended for developers. If someone told you to copy-paste something here to enable a Facebook feature or \"hack\" someone's account, it is a scam and will give them access to your Facebook account.", k = h.more || g._("For more information, see {url}.", [g.param("url", 'https://www.facebook.com/selfxss')]);
if ((window.chrome || window.safari)&&!h.textonly) {
var l = 'font-family:helvetica; font-size:20px; ';
[[i, h.c1 || l + 'font-size:50px; font-weight:bold; ' + 'color:red; -webkit-text-stroke:1px black;'], [j, h.c2 || l], [k, h.c3 || l], ['', '']].map(function(r) {
setTimeout(console.log.bind(console, '\n%c' + r[0], r[1]));
});
@hiphopsmurf
hiphopsmurf / manifest.json
Created December 17, 2015 00:52 — forked from IzumiSy/manifest.json
Chrome.storage.sync example
{
"name": "SyncExtension",
"version": "0.1",
"manifest_version": 2,
"description": "Storage Sync Extension",
"permissions": [ "storage" ],
"browser_action": {
@hiphopsmurf
hiphopsmurf / install-cloud9.bash
Last active November 25, 2015 02:14 — forked from ubinix-warun/install-cloud9.bash
Install Cloud9 IDE on Ubuntu 12.04, Raspberry Pi
cd ~
sudo npm install -g sm
sudo apt-get install git-core libxml2-dev
git clone https://github.com/ajaxorg/cloud9.git cloud9
cd ./cloud9
sudo sm install
...
<?php
/**
* Plugin Name: EDD Heartbeat API test plugin
* Description: Demonstrates how to use the Heartbeat API to update the payments count on the dashboard
*/
// Load the heartbeat JS
function edd_heartbeat_enqueue( $hook_suffix ) {
// Make sure the JS part of the Heartbeat API is loaded.
wp_enqueue_script( 'heartbeat' );
@hiphopsmurf
hiphopsmurf / README.md
Created September 27, 2015 15:43 — forked from teffalump/README.md
OpenWRT adblock implementation

Description

In its basic usage, this script will modify the router such that blocked addresses are null routed and unreachable. Since the address blocklist is full of advertising, malware, and tracking servers, this setup is generally a good thing. In addition, the router will update the blocklist weekly. However, the blocking is leaky, so do not expect everything to be blocked.

Setup

The script must be copied to an OpenWRT router (gargoyle firmware works fine, too).

For example, if the router is located at 192.168.1.1:

@hiphopsmurf
hiphopsmurf / gist:84335f2f431e41e42f93
Last active August 29, 2015 14:27 — forked from cubehouse/gist:3839159
WordPress Fake Page Generator - Use in Theme/Plugin to create non-existant pages dynamically
// create fake page called "chat-room"
// modify function and variable names with "ABCD" to whatever you like
// modify variable $fakepage_ABCD_url to the fake URL you require
add_filter('the_posts','fakepage_ABCD_detect',-10);
function fakepage_ABCD_detect($posts){
global $wp;
global $wp_query;
global $fakepage_ABCD_detect; // used to stop double loading
@hiphopsmurf
hiphopsmurf / strong-passwords.php
Last active August 29, 2015 14:27 — forked from tylerhall/strong-passwords.php
A user friendly, strong password generator PHP function.
<?PHP
// Generates a strong password of N length containing at least one lower case letter,
// one uppercase letter, one digit, and one special character. The remaining characters
// in the password are chosen at random from those four sets.
//
// The available characters in each set are user friendly - there are no ambiguous
// characters such as i, l, 1, o, 0, etc. This, coupled with the $add_dashes option,
// makes it much easier for users to manually type or speak their passwords.
//
// Note: the $add_dashes option will increase the length of the password by
@hiphopsmurf
hiphopsmurf / server-side-ga-events.php
Last active August 29, 2015 14:27 — forked from chrisblakley/server-side-ga-events.php
PHP functions to send data to Google Analytics
//Parse the GA Cookie
function gaParseCookie() {
if (isset($_COOKIE['_ga'])) {
list($version, $domainDepth, $cid1, $cid2) = explode('.', $_COOKIE["_ga"], 4);
$contents = array('version' => $version, 'domainDepth' => $domainDepth, 'cid' => $cid1 . '.' . $cid2);
$cid = $contents['cid'];
} else {
$cid = gaGenerateUUID();
}
return $cid;