Skip to content

Instantly share code, notes, and snippets.

View verygoodplugins's full-sized avatar

Very Good Plugins verygoodplugins

View GitHub Profile
@verygoodplugins
verygoodplugins / edd-custom-parameters.php
Created December 19, 2023 17:19
Store additional customer parameters during an EDD license check
<?php
function store_additional_license_parameters( $response, $args, $license_id ) {
$data = array_map( 'sanitize_text_field', $_REQUEST );
if ( $response['license'] == 'valid' ) {
$user = get_user_by( 'email', $response['customer_email'] );
@verygoodplugins
verygoodplugins / wpf-fooevents-sync-multiple-event-fields.php
Created November 29, 2023 16:10
Syncs FooEvents event data to separate custom fields on the attendee's contact record for each event.
<?php
/**
* Utility function for getting any FooEvents attendees from a WooCommerce order
* @param WC_Order $order
* @return array Attendees
*/
function get_foo_attendees_from_order( $order ) {
$attendees = array();
@verygoodplugins
verygoodplugins / wpf-non-blocking-during-login.php
Last active September 27, 2023 11:11
Sends API calls non-blocking during login.
<?php
/**
* Sends API calls non-blocking during login.
*
* This is useful if your CRM has a slow API, it will allow the user to log in
* without any noticable delay. However, if the API is offline or fails to process
* the request, no error will be logged and there will be no indication it failed.
*
* @param array $parsed_args The HTTP API request args.
@verygoodplugins
verygoodplugins / wpf-allow-unsafe-crm-urls.php
Last active April 4, 2024 21:36
Bypass WordPress' unsafe URL check for CRM connection
<?php
/**
*
* This sometimes fixes the error "A valid URL was not provided." wen connecting to self
* hosted CRMs like Mautic, FluentCRM, or FunnelKit.
*
* @param array $args HTTP request arguments.
* @param string $url The request URL.
* @return array HTTP request arguments.
*/
@verygoodplugins
verygoodplugins / wpf-all-sites.php
Last active August 28, 2023 22:19
Stores log of all sites that call home looking for updates
<?php
/*
Plugin Name: WPF All Sites
Plugin URI: verygoodplugins.com
Description: Stores log of all sites that call home looking for updates
Version: 1.0
Author: vergoodplugins
Author URI: verygoodplugins.com
License:
@verygoodplugins
verygoodplugins / wpf-dont-sync-free-orders.php
Created August 10, 2023 12:55
Prevent the Enhanced Ecommerce addon from syncing free orders to the CRM
<?php
function wpf_dont_sync_free_orders( $order_args ) {
if ( empty( $order_args['total'] ) ) {
return false;
}
return $order_args;
}
@verygoodplugins
verygoodplugins / wpf-add-field-keys-to-names.php
Created July 19, 2023 13:03
Appends each CRM field's internal ID to the field label in the dropdowns.
<?php
function add_field_keys_to_names( $fields ) {
foreach ( $fields as $i => $category ) {
foreach ( $category as $key => $label ) {
$fields[ $i ][ $key ] = $label .= ' (' . $key . ')';
}
}
@verygoodplugins
verygoodplugins / wpf-inherit-from-am360.php
Created July 13, 2023 11:40
Inherit access rules from ActiveMember360
<?php
/**
* Inherits access rules and redirects from ActiveMember360 for posts and pages.
*
* @param array $settings The WP Fusion settings on the post.
* @param WP_Post|int $post_id The post or post ID.
* @return array The settings.
*/
function inherit_am360_access_rules( $settings, $post_id ) {
@verygoodplugins
verygoodplugins / queryWooCommerce.py
Last active February 6, 2024 12:28
Python script for querying the WooCommerce REST API using ChatGPT
import openai
import requests
import re
import json
openai.api_key = "X"
# Define WooCommerce credentials.
site_url = "https://yoursite.com/"
@verygoodplugins
verygoodplugins / edd-auto-activate-sites.php
Created February 9, 2023 13:25
Allow active licenses to get updates if they're not at the limit, no matter what.
<?php
/**
* Allow active licenses to get updates if they're not at the limit, no matter what.
*
* @param bool $is_active Whether the site is active or not.
* @param int $license_id The license ID.
* @param string $passed_site_url The site URL.
*
* @return bool Whether the site is active or not.
*/