Skip to content

Instantly share code, notes, and snippets.

View goldhat's full-sized avatar

Joel Milne goldhat

View GitHub Profile
@goldhat
goldhat / functions.php
Last active July 14, 2018 20:43
Script Inclusions
<?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' )
) {
<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 September 16, 2017 13:02
Override templates support for themes provided in WordPress plugin
<?php
class Clay_Template {
public $override_dir;
public $hook_prefix;
public function __construct( $override_dir, $hook_prefix ) {
$this->override_dir = $override_dir;
@goldhat
goldhat / QuizMaster_Helper_CopyPost.php
Created June 6, 2017 07:54
QuizMaster Helper CopyPost
<?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 June 4, 2017 20:40
quizmaster_extension_autoload.php
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' ) {
<?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 16:16
QuizMaster plugin - associate question with quiz programmatically
<?php
/*
* $quiz QuizMaster_Model_Quiz
* $question QuizMaster_Model_Question
*/
QuizMaster_Model_Quiz_Question::associate( $quiz->getId(), $question->getId() );
@goldhat
goldhat / gpls_rulegroups.php
Created April 8, 2017 14:50
Filter gpls_rulegroups from Gravity Perks Submission Limits
// 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 March 8, 2017 01:59
Signup Error from GFSignup::get( $key )
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 February 18, 2017 17:24
QuizMaster Access Code Processing Functions
/* Global Scope (Not On Ready) */
function quizmasterProcessAccessCode( codeEntered, code ) {
if( codeEntered == code ) {
console.log("code is correct");
quizmasterGrantAccessByCode();
} else {
quizmasterDenyAccessByCode();
}
}