Want to create a Gist from your editor, the command line, or the Services menu? Here's how.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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? |
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.
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#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", |
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.
elem.offsetLeft
,elem.offsetTop
,elem.offsetWidth
,elem.offsetHeight
,elem.offsetParent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ) ); | |
} | |
} |
OlderNewer