Skip to content

Instantly share code, notes, and snippets.

View langlers's full-sized avatar

Daniel Bond | Langlers WebWorks langlers

View GitHub Profile
@defunkt
defunkt / clients.md
Created April 18, 2010 14:09
A list of Gist clients.

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@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)
@troy
troy / send_remote_syslog.php
Last active April 6, 2023 18:19
Send UDP remote syslog message from PHP (RFC 3164)
# replace PAPERTRAIL_HOSTNAME and PAPERTRAIL_PORT
# see http://help.papertrailapp.com/ for additional PHP syslog options
function send_remote_syslog($message, $component = "web", $program = "next_big_thing") {
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
foreach(explode("\n", $message) as $line) {
$syslog_message = "<22>" . date('M d H:i:s ') . $program . ' ' . $component . ': ' . $line;
socket_sendto($sock, $syslog_message, strlen($syslog_message), 0, PAPERTRAIL_HOSTNAME, PAPERTRAIL_PORT);
}
socket_close($sock);
@strangerstudios
strangerstudios / pmpro_cancel_on_next_payments_date.php
Last active July 5, 2024 05:12
Change PMPro membership cancellation to set expiration date for next payment instead of cancelling immediately.
/*
Change cancellation to set expiration date for next payment instead of cancelling immediately.
Assumes orders are generated for each payment (i.e. your webhooks/etc are setup correctly).
Since 2015-09-21 and PMPro v1.8.5.6 contains code to look up next payment dates via Stripe and PayPal Express APIs.
*/
//before cancelling, save the next_payment_timestamp to a global for later use. (Requires PMPro 1.8.5.6 or higher.)
function my_pmpro_before_change_membership_level($level_id, $user_id) {
//are we on the cancel page?
@danfinlay
danfinlay / How to download streaming video.md
Last active June 29, 2024 04:41
How to download a streaming video with Google Chrome

How to download streaming video

Streaming just means a download that they don't want you to keep. But Chrome's developer tools make it easy to access what's really going on under the hood.

Open Developer Tools

From the page where you want to download some things, go into your chrome menu to open the developer tools. You can either:

1.  (On a mac): Command-option-J
2. (On a PC): Control-alt-J
@strangerstudios
strangerstudios / assign_pmpro_level_to_role.php
Created February 18, 2014 16:11
Assign a Paid Memberships Pro level based on user role when user roles are updated.
function assign_pmpro_level_to_role($user_id, $role, $old_roles)
{
//we found a role related to pmpro level
if($role == "pmpro_level_1")
{
pmpro_changeMembershipLevel(1, $user_id);
}
elseif($role == "administrator")
{
pmpro_changeMembershipLevel(2, $user_id); //setup level 2 as an all access role or just give them level 1
@james2doyle
james2doyle / jquery-ga-form-submit.js
Created August 5, 2015 18:06
jQuery contact form submit with Google Analytics event
$('#contact-form').submit(function(e) {
// delay the submit
e.preventDefault();
// we need this to call the form in a scoped function
var self = this;
ga('send', {
eventAction: "submit",
eventCategory: "form",
eventLabel: "contact-form",
hitType: "event",
@paulirish
paulirish / what-forces-layout.md
Last active July 18, 2024 22:41
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
@eduard-ungureanu
eduard-ungureanu / ccfm.php
Last active November 10, 2023 14:35
Custom Contact Form Module
<?php
/*Change the thank you message */
class WPC_ET_Builder_Module_Contact_Form extends ET_Builder_Module {
function init() {
$this->name = __( 'Contact Form', 'et_builder' );
$this->slug = 'et_pb_contact_form';
$this->whitelisted_fields = array(
'captcha',
'email',
@lots0logs
lots0logs / functions.php
Last active November 10, 2023 14:32
Divi Contact Form Module Customization
<?php
function my_et_theme_setup() {
if ( class_exists( 'ET_Builder_Module_Contact_Form' ) ) {
get_template_part( 'my-main-modules' );
$et_pb_contact = new My_ET_Builder_Module_Contact_Form();
remove_shortcode('et_pb_contact_form');
add_shortcode('et_pb_contact_form', array( $et_pb_contact, '_shortcode_callback' ) );
}
}