Skip to content

Instantly share code, notes, and snippets.

View goldhat's full-sized avatar

Joel Milne goldhat

View GitHub Profile
@goldhat
goldhat / xml-pq-export.xml
Created February 12, 2017 17:04
WP Pro Quiz Exports
<?xml version="1.0" encoding="utf-8"?>
<wpProQuiz><header version="0.37" exportVersion="1"/><data><quiz><title titleHidden="false"><![CDATA[Demo Tommy Quiz 1]]></title><text><![CDATA[This is a Demo of WP Pro Quiz functionality. The settings are very open ended, so as to permit the test user to freely skip questions and return to previous ones.]]></text><category>Demo</category><resultText gradeEnabled="true"><text prozent="15"><![CDATA[These are your graduation results!]]></text><text prozent=""><![CDATA[]]></text></resultText><btnRestartQuizHidden>false</btnRestartQuizHidden><btnViewQuestionHidden>false</btnViewQuestionHidden><questionRandom>false</questionRandom><answerRandom>false</answerRandom><timeLimit>600</timeLimit><showPoints>true</showPoints><statistic activated="true" ipLock="1440"/><quizRunOnce type="1" cookie="false" time="0">false</quizRunOnce><numberedAnswer>true</numberedAnswer><hideAnswerMessageBox>false</hideAnswerMessageBox><disabledAnswerMark>false</disabledAnswerMark><showMaxQuestion show
@goldhat
goldhat / stats-save.php
Created February 4, 2017 14:47
Stats Save
public function save($quiz = null) {
$quizId = $this->_post['quizId'];
$array = $this->_post['results'];
$lockIp = $this->getIp();
$userId = get_current_user_id();
if ($lockIp === false) {
return false;
}
@goldhat
goldhat / show-quiz-box.php
Created January 27, 2017 23:58
Quiz showQuizBox()
public function showQuizBox($questionCount)
{
$globalPoints = 0;
$json = array();
$catPoints = array();
?>
<div style="display: none;" class="quizMaster_quiz">
<ol class="quizMaster_list">
<?php
$index = 0;
@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]=>
@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 / 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 / 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 / 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: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();
[acf-render name="acfr_demo_text"]