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 | |
/* | |
Plugin Name: AppPresser In App Purchases for Indeed Memberships | |
Plugin URI: https://apppresser.com | |
Description: This plugin listens for in app purchases or cancellations and adds/removes members from a membership level. | |
Version: 1.0.0 | |
Author: Scott Bolinger | |
Author URI: https://apppresser.com | |
License: GPLv2 | |
*/ |
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
// to update a property in an object, for example a title | |
setMyState({ | |
...currentState, | |
title: newTitle, | |
}); | |
/* Explanation below... | |
// we have an object set as state |
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 | |
// Add groups to member list | |
// add this code to a custom plugin | |
function app_extend_bp_member($response, $request, $user) { | |
$joined_groups = array(); | |
$group_ids = groups_get_user_groups($user->ID); | |
foreach($group_ids['groups'] as $id) { | |
$current_group = groups_get_group(array('group_id' => $id)); | |
if($current_group->name !== 'hidden') { | |
$joined_groups[] = $current_group->name; |
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
// listen for all clicks on anything. You could change document to a selector like #content to make it more efficient. | |
$(document).on('click', function( e ) { | |
// if this is a link, and the href does not contain our domain, it's an external link. Track it. | |
if( e.target.href && e.target.href.indexOf( window.location.hostname ) < 0 ) { | |
ga('send', 'event', { | |
eventCategory: 'Outbound Link', | |
eventAction: 'click', | |
eventLabel: e.target.href, // the outbound link url will appear as the event label in GA. Find under Behavior -> Events -> Event Label | |
transport: 'beacon' // not supported in some versions of IE | |
}); |
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 | |
// Add this code to a custom plugin on your site to add customer emails to your abandoned checkout flow | |
// Requires the free plugin code here: https://hollerwp.com/woo-checkout-save-email/ | |
// You need to install this first: composer require drewm/mailchimp-api | |
// see https://github.com/drewm/mailchimp-api | |
use \DrewM\MailChimp\MailChimp; | |
$MailChimp = new MailChimp('abc123abc123abc123abc123abc123-us1'); // change this to your MC API key | |
// this action fires when a new email is added to your checkout |
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 | |
// make email the first field on the WooCommerce checkout page | |
add_filter( 'woocommerce_checkout_fields', 'sb_edit_checkout_fields' ); | |
function sb_edit_checkout_fields( $fields ) { | |
// make email first | |
$fields['billing']['billing_email']['priority'] = 4; | |
return $fields; |
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 | |
// add this code to a theme functions.php or custom plugin | |
add_filter( 'woocommerce_checkout_fields' , 'sb_override_checkout_fields' ); | |
// Our hooked in function - $fields is passed via the filter! | |
function sb_override_checkout_fields( $fields ) { | |
$fields['shipping']['shipping_phone'] = array( | |
'label' => __('Phone', 'woocommerce'), | |
'placeholder'=> _x('Phone', 'placeholder', 'woocommerce'), |
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 | |
// put this code in your theme functions.php or a custom plugin | |
add_filter( 'woocommerce_checkout_fields' , 'sb_remove_woo_checkout_fields' ); | |
function sb_remove_woo_checkout_fields( $fields ) { | |
// remove some billing fields | |
unset($fields['billing']['billing_company']); | |
unset($fields['billing']['billing_address_2']); |
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 | |
// Support Variation Swatches for WooCommerce plugin in AppPresser | |
// put this code in a custom plugin | |
add_filter( 'appcommerce_attribute_terms', function( $terms ) { | |
foreach( $terms as $key => $option) : | |
// if you have a different plugin, just replace 'product_attribute_color' with the key from your plugin | |
$terms[$key]->attribute_color = get_term_meta( $option->term_id, 'product_attribute_color', 1 ); | |
$terms[$key]->attribute_image = wp_get_attachment_url( get_term_meta( $option->term_id, 'product_attribute_image', 1 ) ); | |
endforeach; |
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 | |
// add this code to a custom plugin | |
add_filter('bp_rest_members_get_items_query_args', function( $args, $request ) { | |
// These are just examples. Find available arguments here: https://codex.buddypress.org/developer/bp_user_query/ | |
$args['search_terms'] = 'football'; | |
$args['exclude'] = '1,2,3'; | |
return $args; |
NewerOlder