Skip to content

Instantly share code, notes, and snippets.

View mwhiteley16's full-sized avatar

Matt Whiteley mwhiteley16

View GitHub Profile
@mwhiteley16
mwhiteley16 / sec-coupons
Last active August 29, 2015 14:03
Switch to Coupon on SEC Smart Offers Admin Page (Change made to plugin - must retain for updates) - Lines 15-19 updated
public static function column_display( $column_name, $id ) {
global $post;
$item = SEC_Offer::get_instance( $id );
if ( !$item )
return; // return for that temp post
switch ( $column_name ) {
case 'info':
$type = $item->get_type();
@mwhiteley16
mwhiteley16 / jquery.lazyload.js
Created November 9, 2015 14:34
jQuery Lazy Load
/*
* Lazy Load - jQuery plugin for lazy loading images
*
* Copyright (c) 2007-2013 Mika Tuupola
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/mit-license.php
*
* Project home:
* http://www.appelsiini.net/projects/lazyload
@mwhiteley16
mwhiteley16 / loading-graphic-example.php
Created May 3, 2016 13:53
Loading Graphic Example
<div class="loading-example-container" style="display: block; float: left;width: 100%;padding: 50px;text-align: center;font-size: 40px;line-height: 40px;">
Page Loading...<br><i class="fa fa-spinner fa-pulse"></i>
</div>
<div class="loading-example-content" style="display: none;">
<img src="https://whiteleydesigns.com/wp-content/uploads/2016/05/nature1.jpg" alt="Nature Image 1" width="1675" height="950" class="alignnone size-full wp-image-859" />
<img src="https://whiteleydesigns.com/wp-content/uploads/2016/05/nature2.jpg" alt="Nature Image 2" width="1675" height="950" class="alignnone size-full wp-image-860" />
<img src="https://whiteleydesigns.com/wp-content/uploads/2016/05/nature3.jpg" alt="Nature 3" width="1080" height="1440" class="alignnone size-full wp-image-862" />
<img src="https://whiteleydesigns.com/wp-content/uploads/2016/05/nature4.jpg" alt="Nature 4" width="1080" height="715" class="alignnone size-full wp-image-865" />
<img src="https://whiteleydesigns.com/wp-content/uploads/2016/05/nature5.jpg
@mwhiteley16
mwhiteley16 / jquery.cookie.js
Created May 4, 2017 13:18
Javascript Cookie v2.1.4
[
{
"key": "group_593ebd9564c27",
"title": "User Support Fields",
"fields": [
{
"key": "field_593ebd9f48bd8",
"label": "Support Requests",
"name": "support_requests",
"type": "repeater",
@mwhiteley16
mwhiteley16 / edd-recurring-emails.php
Last active November 14, 2017 19:12
EDD Recurring Emails 1
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/**
* The Recurring Emails Class
*
* @since 2.4
*/
@mwhiteley16
mwhiteley16 / settings.php
Created November 14, 2017 19:16
EDD Recurring Emails 2
<?php
/**
* Register our settings section
*
* @since 2.4
* @return array
*/
function edd_recurring_settings_section( $sections ) {
@mwhiteley16
mwhiteley16 / gist:80d9f7abaae28491fe2b415a9d842117
Created December 31, 2017 19:08
Change User Role when Cancelled EDD Subscription
function wd_downgrade_fieldstaff( $sub_id, $subscription ) {
$u = new WP_User( $subscription->customer->user_id );
$u->remove_role( 'fieldstaff' );
$u->add_role( 'subscriber' );
}
add_action( 'edd_subscription_cancelled', 'wd_downgrade_fieldstaff', 10, 2 );
@mwhiteley16
mwhiteley16 / gist:2bacdd9d9b920c20af6d3711c6bccc6b
Created January 5, 2018 15:17
Create Post when Gravity Form Submitted
// Create Field Staff post when subscription is completed
add_action( 'gform_after_submission_4', 'wd_create_map_post', 10, 4);
function wd_create_map_post($entry, $form) {
global $post;
global $wp_query;
$name_first = $entry['10.3'];
$name_last = $entry['10.6'];
$state = $entry['12'];
@mwhiteley16
mwhiteley16 / login-count.php
Created February 8, 2018 13:39
Count Logins
<?php
// Create simple meta field to count number of logins
add_action( 'wp_login', 'wd_login_counter' );
function wd_login_counter( $username ){
$userdata = get_user_by( 'login', $username );
$login_count = get_user_meta( $userdata->ID, 'wd_login_count', true );
if ( !is_numeric($login_count) ) $login_count = 0;
$login_count = intval($login_count) + 1;
update_user_meta($userdata->ID, 'wd_login_count', $login_count);
}