Skip to content

Instantly share code, notes, and snippets.

Avatar

Joel Milne goldhat

View GitHub Profile
@goldhat
goldhat / functions.php
Last active Jul 14, 2018
Script Inclusions
View functions.php
<?php
// Header Collapsed CSS
if ( is_page_template( 'page-templates/template-learn-patacademy.php' )
|| is_page_template( 'page-templates/template-learn-mikesvideos.php' )
|| is_page_template( 'page-templates/template-learn-rcacademy.php' )
|| is_page_template( 'page-templates/template-learn-quiz.php' )
|| is_page_template( 'page-templates/template-learn-questionbank.php' )
|| is_page_template( 'page-templates/template-bookmarkedquestions.php' )
) {
View segmented-progress-bar-html.html
<div class="segmented-progress-bar" data-segments="9,1,4,287" data-total="301">
<span class="segment segment-10" style="width: 3.79175px;"></span>
<span class="segment segment-20" style="width: 0.421306px;"></span>
<span class="segment segment-30" style="width: 1.68522px;"></span>
<span class="segment segment-90" style="width: 120.915px;"></span>
</div>
@goldhat
goldhat / Clay_Templates.php
Created Sep 16, 2017
Override templates support for themes provided in WordPress plugin
View Clay_Templates.php
<?php
class Clay_Template {
public $override_dir;
public $hook_prefix;
public function __construct( $override_dir, $hook_prefix ) {
$this->override_dir = $override_dir;
View QuizMaster_Helper_CopyPost.php
<?php
class QuizMaster_Helper_CopyPost {
private $postTypes = array();
public function __construct( $postTypes = array() ) {
if( empty( $postTypes )) {
$this->postTypes = false;
} else {
@goldhat
goldhat / gist:19b4756edb1b2a0dacb6b8982618907c
Created Jun 4, 2017
quizmaster_extension_autoload.php
View gist:19b4756edb1b2a0dacb6b8982618907c
public static function autoload( $class, $dir ) {
$registeredExtensions = $this->register();
print '<pre>';
var_dump( $registeredExtensions );
print '</pre>';
foreach( $registeredExtensions as $ext => $extSettings ) {
if( $extSettings['type'] == 'pro' ) {
View gist:3e1da8eaaefa3b207abaf600e3c70614
<?php
// time period handling segment
$time_period = $this->_args['time_period'];
$time_period_sql = false;
if( $time_period === false ) {
// no time period
} else if( intval( $time_period ) > 0 ) {
$time_period_sql = $wpdb->prepare( 'date_created BETWEEN DATE_SUB(utc_timestamp(), INTERVAL %d SECOND) AND utc_timestamp()', $this->_args['time_period'] );
} else {
@goldhat
goldhat / quizmaster-associate-quiz-question.php
Last active May 16, 2017
QuizMaster plugin - associate question with quiz programmatically
View quizmaster-associate-quiz-question.php
<?php
/*
* $quiz QuizMaster_Model_Quiz
* $question QuizMaster_Model_Question
*/
QuizMaster_Model_Quiz_Question::associate( $quiz->getId(), $question->getId() );
@goldhat
goldhat / gpls_rulegroups.php
Created Apr 8, 2017
Filter gpls_rulegroups from Gravity Perks Submission Limits
View gpls_rulegroups.php
// Method A - using form ID
add_filter('gpls_rulegroups', 'gpls_globalize');
function gpls_globalize( $rulegroups ) {
return array_merge( $rulegroups, GPLS_RuleGroup::load_by_form( 2 ) );
}
// Method B - using rulegroup id (GF feed ID)
add_filter('gpls_rulegroups', 'gpls_globalize');
function gpls_globalize( $rulegroups ) {
$rulegroups[] = GPLS_RuleGroup::load_by_id( 60 ) );
@goldhat
goldhat / gist:73db243cddb7efa2e12ad70219566721
Created Mar 8, 2017
Signup Error from GFSignup::get( $key )
View gist:73db243cddb7efa2e12ad70219566721
object(WP_Error)#693 (2) {
["errors"]=>
array(1) {
["already_active"]=>
array(1) {
[0]=>
string(27) "The user is already active."
}
}
["error_data"]=>
@goldhat
goldhat / access-code.php
Created Feb 18, 2017
QuizMaster Access Code Processing Functions
View access-code.php
/* Global Scope (Not On Ready) */
function quizmasterProcessAccessCode( codeEntered, code ) {
if( codeEntered == code ) {
console.log("code is correct");
quizmasterGrantAccessByCode();
} else {
quizmasterDenyAccessByCode();
}
}