Skip to content

Instantly share code, notes, and snippets.

View pippinsplugins's full-sized avatar

Pippin Williamson pippinsplugins

View GitHub Profile
@pippinsplugins
pippinsplugins / gist:146c6f90bc8194c7dba1
Last active May 9, 2017 23:13
This is a simple example that shows how we can maintain backwards compatibility in a plugin for data that used to be stored in post meta but is now stored in a taxonomy term. When this change was made, a new `edd_get_commission_status()` function was introduced, but before this function existed, the status was retrieved by calling `get_post_meta…
<?php
/**
* Filters get_post_meta() to ensure old commission status checks don't fail
*
* The status for commission records used to be stored in postmeta, now it's stored in a taxonomy
*
* @access private
* @since 2.8
* @return mixed
@pippinsplugins
pippinsplugins / gist:92e53cc53649a922a10e
Created May 7, 2014 20:56
Sample custom field for EDD FES
<?php
// Begin FES integration
// add button to the post button listing
function fes_shipping_field_button( $title ) {
if ( version_compare( fes_plugin_version, '2.2', '>=' ) ) {
echo '<button class="fes-button button" data-name="edd_simple_shipping" data-type="action" title="' . $title . '">'. __( 'Shipping', 'edd-simple-shipping' ) . '</button>';
}
}
add_action('fes_custom_post_button', 'fes_shipping_field_button');
@pippinsplugins
pippinsplugins / gist:11402562
Last active December 15, 2021 17:07
Custom user fields for Restrict Content Pro
<?php
/*
Plugin Name: Restrict Content Pro - Custom User Fields
Description: Illustrates how to add custom user fields to the Restrict Content Pro registration form that can also be edited by the site admins
Version: 1.0
Author: Pippin Williamson
Author URI: http://pippinsplugins.com
Contributors: mordauk
*/
@pippinsplugins
pippinsplugins / gist:9842051
Created March 28, 2014 20:15
Sample of how to extend a class in PHP
<?php
/*
* Plugin Name: PD101 Extending Classes Example
* Description: An example of how to extend a class
* Author: Pippin Williamson
*/
class PD101_Base {
<?php
/**
* Plugin Name: Update Previous Order Numbers for EDD
* Description: For users of the sequential order number beta, use this before you get new orders to have your previous orders sequentially numbered
* Version: 0.1
* Author: Chris Christoff
* Author URI: http://www.chriscct7.com
*/
function update_script_edd_seq_numbers(){
<?php
function get_the_user_ip() {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip = $_SERVER['REMOTE_ADDR'];
@pippinsplugins
pippinsplugins / gist:9627938
Created March 18, 2014 19:46
Jetpack errors . . . .
[Tue Mar 18 19:19:44 2014] [error] [client 54.241.31.99] Stripe Notice: Undefined property of Stripe_Customer instance: customer
[Tue Mar 18 19:35:21 2014] [error] [client 72.209.182.221] PHP Warning: stripos() expects parameter 1 to be string, array given in /nas/wp/www/cluster-1117/pippinsplugins/wp-content/plugins/jetpack/modules/shortcodes/dailymotion.php on line 22, referer: http://pippinsplugins.com/wp-admin/post-new.php
[Tue Mar 18 19:35:21 2014] [error] [client 72.209.182.221] PHP Warning: preg_match_all() expects parameter 2 to be string, array given in /nas/wp/www/cluster-1117/pippinsplugins/wp-content/plugins/jetpack/modules/shortcodes/dailymotion.php on line 29, referer: http://pippinsplugins.com/wp-admin/post-new.php
[Tue Mar 18 19:35:21 2014] [error] [client 72.209.182.221] PHP Warning: stripos() expects parameter 1 to be string, array given in /nas/wp/www/cluster-1117/pippinsplugins/wp-content/plugins/jetpack/modules/shortcodes/blip.php on line 10, referer: http://pippinsplugins.com/wp-admin
@pippinsplugins
pippinsplugins / gist:9557012
Created March 14, 2014 21:10
Send an email anytime a payment is recurring through EDD Recurring Payments
<?php
function pw_edd_recurring_payment_received_notice( $payment, $parent_id, $amount, $txn_id, $unique_key ) {
$user_id = edd_get_payment_user_id( $parent_id );
$email = edd_get_payment_user_email( $parent_id );
$user_data = get_userdata( $user_id );
$subject = 'Payment Received';
$message = "Hello $usera_data->display_name, your payment for $amount has been received. Thanks!";
@pippinsplugins
pippinsplugins / gist:9330494
Created March 3, 2014 17:50
Modify the admin notification sent out when new users signup
<?php
function pw_rcp_custom_email_notice( $message, $user_id ) {
$user_data = get_userdata( $user_id );
$user_email = $user_data->user_email;
$message = "Hello admin, this is a custom alert message!\n\n";
$message .= "$user_email just signed up for an account.";
return $message;
@pippinsplugins
pippinsplugins / gist:9201867
Created February 25, 2014 03:06
Simple example of how to use SCRIPT_DEBUG to load non-minified assets
<?php
// Use minified libraries if SCRIPT_DEBUG is turned off
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_enqueue_script( 'my-script-handle', plugin_dir_url( __FILE__ ) . 'assets/my-file' . $suffix . '.js', array( 'jquery' ) );