Skip to content

Instantly share code, notes, and snippets.

View 1wdtv's full-sized avatar

1WD.tv - Make Money With Divi 1wdtv

View GitHub Profile
@cgilchrist
cgilchrist / replace_text_with_url_param.js
Created February 15, 2011 00:11
Replace some text on your page with the value of a URL parameter
<script type="text/javascript">
var getUrlParams = function() {
var params = {}, hash;
var hashes = decodeURI(window.location.href).replace(/\+/g," ").slice(window.location.href.indexOf('?') + 1).split('&');
for (var i=0; i<hashes.length; i++) {
hash = hashes[i].split('=');
params[hash[0]] = hash[1];
}
return params;
};
@mhawksey
mhawksey / gist:1276293
Last active January 6, 2026 22:10
Google App Script to insert data to a google spreadsheet via POST or GET - updated version as per https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@strangerstudios
strangerstudios / gist:1421978
Created December 2, 2011 05:56
Paid Memberships Pro Different Payment Options at Checkout for One Level
/*
PMPro Example Offering Monthly and Annual Options on Checkout Page
This code assumes your levels have an annual recurring cost.
The first function converts your annual prices into monthly prices.
*/
function my_getMonthlyPriceFromAnnualPrice($price)
{
//divide by 10 and round down to nearest dollar
return floor($price / 10);
}
@strangerstudios
strangerstudios / gist:2185226
Last active April 16, 2021 01:15
Delete the WordPress User When a Paid Memberships Pro Member Cancels His Account
/*
Requires PMPro v1.4+
Code to delete WP user accounts when a member cancels their PMPro account.
Users are not deleted if:
(1) They are not cancelling their membership (i.e. $level_id != 0)
(2) They are an admin.
(3) The level change was initiated from the WP Admin Dashboard
(e.g. when an admin changes a user's level via the edit user's page)
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
@strangerstudios
strangerstudios / my_pmpro_confirmation_redirect.php
Last active July 6, 2021 20:16
Redirect Paid Memberships Pro Confirmation to Another Page Based on Level
/*
This code will redirect users from the default PMPro confirmation page to a specific page depending on their level.
Set the confirmation_pages array. Array keys should be membership level ids and the values are the page ids. So array(1=>2) will redirect membership level with id = 1 to the page with id = 2.
*/
function my_pmpro_confirmation_redirect()
{
$confirmation_pages = array(1 => 2); //change this use your membership level ids and page ids
global $pmpro_pages;
@trepmal
trepmal / remote-login.php
Created June 21, 2012 20:49
[WordPress Plugin] Remote Login
<?php
/*
Plugin Name: Remote Login
Description: Log into the site with creds that work on remote site (as defined in plugin). The remote site must have XML-RPC enabled.
Author: Kailey Lampert
Author URI: http://kaileylampert.com/
THIS IS NOT COMPLETE - DO NOT USE IN PRODUCTION
The remote site (defined below in $server) is the "master" site.
@alexkingorg
alexkingorg / maybe-include-plugin.php
Created July 6, 2012 14:25
Conditional loading of a plugin within a WordPress theme.
<?php
// Run this code on 'after_theme_setup', when plugins have already been loaded.
add_action('after_setup_theme', 'my_load_plugin');
// This function loads the plugin.
function my_load_plugin() {
// Check to see if your plugin has already been loaded. This can be done in several
// ways - here are a few examples:
@hissy
hissy / gist:3613306
Last active June 26, 2023 22:56
[WordPress] change next / previous post link ordering
<?php
/**
* Customize Adjacent Post Link Order
*/
function my_custom_adjacent_post_where($sql) {
if ( !is_main_query() || !is_singular() )
return $sql;
$the_post = get_post( get_the_ID() );
$patterns = array();
@strangerstudios
strangerstudios / gist:3845777
Created October 6, 2012 18:50
All Access Levels with Paid Memberships Pro and PMPro-Addon-Packages .1.2+
/*
Set levels as "all access levels" so members of these levels will be able to view all Addon Packages.
Requires Paid Memberships Pro and the pmpro-addon-packages plugin.
*/
function my_pmproap_all_access_levels($levels, $user_id, $post_id)
{
//I'm just adding the level, but I could do some calculation based on the user and post id to programatically give access to content
$levels = array(16);
return $levels;
}
@pippinsplugins
pippinsplugins / gist:4118759
Last active April 21, 2016 02:54
Change the license expiration length in EDD Software Licensing
function pw_edd_license_length( $length, $payment_id, $download_id, $license_id ) {
if( $download_id == 14 )
return '+2 year'; // give a 2 year expiration for product ID 14
return '+1 year'; // this is default
}
add_filter( 'edd_sl_license_exp_length', 'pw_edd_license_length', 10, 4 );