Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / gist:1389944
Created November 23, 2011 21:17
Paid Memberships Pro Extra Checkout/Profile Fields Example
<?php
/*
Adding First and Last Name to Checkout Form
*/
//add the fields to the form
function my_pmpro_checkout_after_password()
{
if(!empty($_REQUEST['firstname']))
$firstname = $_REQUEST['firstname'];
@strangerstudios
strangerstudios / gist:3678054
Last active August 31, 2020 17:21
Extend Expiration Dates For Renewed Memberships in Paid Memberships Pro
/*
Important note! This code is included in PMPro versions 1.5.7 and later.
Adding this code will add 2x the number of days to the end of the subscription.
*/
//if checking out for the same level, add remaining days to the enddate
function my_pmpro_checkout_level($level)
{
global $pmpro_msg, $pmpro_msgt;
//does this level expire? are they an existing user of this level?
@strangerstudios
strangerstudios / gist:5556801
Last active July 4, 2016 05:15
Replace backticks in WordPress posts, topics, replies, etc with <pre lang="PHP"></pre> so WP-Syntax will highlight it.
/*
Switch `` with <pre lang="PHP"></pre>
*/
function pmpro_code_wrap($content)
{
$content = preg_replace("/`(.*?)`/s", '<pre lang="PHP">$1</pre>', $content);
return $content;
}
add_filter("the_content", "pmpro_code_wrap", -1);
@strangerstudios
strangerstudios / pmpro-customizations.php
Last active October 8, 2018 19:39
Add some fields to checkout with PMPro Register Helper. Both PMPro and PMPro Register Helper must be installed and activated. Save this in your plugins folder and activate. You can also just copy the PHP parts to your active theme's functions.php or your own pmpro-customizations plugin.
<?php
/*
Plugin Name: PMPro Customizations (Register Helper Example)
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for Paid Memberships Pro (Register Helper Example)
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
//we have to put everything in a function called on init, so we are sure Register Helper is loaded
@justintadlock
justintadlock / register-post-type.php
Last active June 3, 2024 13:31
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@cdillon
cdillon / gist:31b4ccc4185dbd4b778b
Last active May 10, 2016 12:35
example of a custom form in WordPress using math Captcha plugin by BestWebSoft
// shortcode: [demo-form]
function demo_form_shortcode( $atts ) {
$name = '';
$email = '';
$company = '';
$errors = array();
if ( isset( $_POST['demo_form_submitted'] )
@johnbillion
johnbillion / hierarchy.php
Last active June 22, 2023 23:05
ASCII WordPress Template Hierarchy
<?php
/*
WordPress Theme Template Hierarchy Last updated for WordPress 5.4
==================================
This diagram is partially simplified for legibility. To view the complete template hierarchy in use on your site see the
Template panel in the Query Monitor plugin.
@psyrendust
psyrendust / elementChange.js
Created November 17, 2015 20:44
Add and remove MutationObserver events to a registered DOM element.
/**
* @typedef MutationCallback
* @param {NodeList} addedNodes A NodeList of elements that have been added to the DOM.
* @param {NodeList} removedNodes A NodeList of elements that have been removed from the DOM.
*/
/**
* Add a MutationObserver to a DOM node.
*
* @example
*
@danieliser
danieliser / metabox-display-fields.php
Created December 21, 2015 06:54
​Replace line 277 of popup-maker/includes/admin/popups/metabox-display-fields.php with
<input type="checkbox" value="1" name="popup_display_position_fixed" id="popup_display_position_fixed" <?php checked( $position_fixed, 1 ); ?>/>
@sankarara
sankarara / monitor-off.ahk
Created March 23, 2016 14:29
AutoHotKey: Turn monitor off with a keyboard shortcut
; This is part of my AutoHotkey [1] script that turns off my monitor when I
; press Win+\.
; It also turns the screensaver on at the same time, so that Windows Live
; Messenger (and any other programs) know I am away.
; I don't have a password on my screensaver, so there is a second version
; (Win+Shift+\) that locks the PC as well.
; Note: Sometimes the monitor comes back on after a second and I have to