Skip to content

Instantly share code, notes, and snippets.

View goldhat's full-sized avatar

Joel Milne goldhat

View GitHub Profile
@goldhat
goldhat / gist:b76db663f1441f71503290b70fbf23aa
Last active October 13, 2016 15:27
WP Activate Plugin
$plugin_path = 'custom-plugin';
activate_plugin( $plugin_path );
$wordpress_path = "/path/to/my/wordpress/install";
// may not be needed if inside WP and hooking into actions
// activate_plugin() is in plugin.php
require_once( $wordpress_path . "/wp-load.php" );
require_once( $wordpress_path . "/wp-admin/includes/plugin.php");
$plugins = array("cforms", "w3-total-cache", "wordpress-seo");
foreach ($plugins as $plugin){
$plugin_path = $wordpress_path."wp-content/plugins/{$plugin}.php";
[acf-render name="acfr_demo_image"]
[acf-render name="acfr_demo_text"]
@goldhat
goldhat / gist:bbc0f169b8fafaf61767944092acd6d3
Created October 31, 2016 16:26
LiveGlam activateWaitlistSubscriber function
public function activateWaitlistSubscriber() {
$productCategories = LiveGlam_ProductCategory::getAll();
if(!empty($productCategories)) {
foreach( $productCategories as $cat ) {
$wsa = new LiveGlam_WaitlistSubscriberActivate( $cat->key );
$subAvailCount = $wsa->subscriptionsAvailableTest();
if( $subAvailCount >= 1 ) {
$subscriberToActivate = $wsa->getWaitlistSubscriberFrontOfLine();
if( $subscriberToActivate ) {
$wsa->activate();
@goldhat
goldhat / gist:8093ad7c6d310baf17b7fcbaa9ccc980
Created November 25, 2016 18:26
WaitList calcShippableCap() method
/*
* Calculate the ShippableCap that represents current maximum shippable units
* ShippableCap varies during OrderPeriod
* Takes into account potential gain/loss of shippable subscribers
* Returns ShippableCap that is compared to current OrderLimit
*/
public function calcShippableCap( $orderLimit, $shippableCount ) {
$dailyLossRate = 0.0065;
$daysRemaining = $this->daysRemainingOrderPeriod();
$periodLossRate = $daysRemaining * $dailyLossRate;
@goldhat
goldhat / gist:5dd7a4d7fdf64dfbefa24f73a29044ba
Created December 7, 2016 16:04
subscriptionsAvailableTest()
public function subscriptionsAvailableTest() {
$settings = new LiveGlam_WaitlistSettings;
$io = new LiveGlam_InventoryOrder;
// get settings and convert to ratio for calculations
$replacement = $settings->getReplacementPercentage() / 100;
$buffer = $settings->getActivationBuffer() / 100;
// get orderLimit for period
$orderLimit = $io->getNextOrderLimitByCategory( $this->productCategory );
@goldhat
goldhat / readme.txt
Last active December 30, 2016 08:01
Example ReadMe for WP plugins
=== ACF Option Pages ===
Contributors: goldhat
Donate link: https://goldhat.ca/donate/
Tags: acf, option pages, options
Requires at least: 4.0
Tested up to: 4.5
Stable tag: 1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@goldhat
goldhat / template.php
Last active January 4, 2017 17:49
Find template functions for WP plugins
/**
* Get template.
*
* Search for the template and include the file.
*
* @since 1.0.0
*
* @see wcpt_locate_template()
*
* @param string $template_name Template to load.
@goldhat
goldhat / answer-type-array.php
Created January 26, 2017 18:14
QuizMaster Questions & Answers
array(1) {
[0]=>
object(WpProQuiz_Model_AnswerTypes)#567 (7) {
["_answer":protected]=>
string(20) "charter
ford
right"
["_html":protected]=>
bool(false)
["_points":protected]=>