Skip to content

Instantly share code, notes, and snippets.

View verygoodplugins's full-sized avatar

Very Good Plugins verygoodplugins

View GitHub Profile
@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-intercom-connect.php
Last active March 13, 2024 22:47
Add new contacts to an alternate CRM (Intercom) when a user registers, and apply tags in Intercom when tags are applied in the primary CRM
<?php
// Put your intercom access token here
define( 'INTERCOM_ACCESS_TOKEN', 'aG9tOjyIyZmMxZDc2X2YxMzBfNDBhZV9hOTVjXzRhZDRlNzBiZWMyMzoxOjA=' );
// We'll save the alternate CRM in a global so it can be re-used if multiple API calls need to be made in the same request
global $intercom;
@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-allow-rss.php
Last active February 11, 2024 18:27
Bypass WP Fusion's content restriction on RSS feed content
<?php
function wpf_allow_rss( $can_access, $user_id, $post_id ) {
if ( is_feed() ) {
$can_access = true;
}
return $can_access;
@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-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-tags-as-body-classes.php
Last active December 14, 2023 13:22
Add tags as classes to the body
<?php
// Adds a current logged in users tags to the <body> element's classes.
function wpf_tags_body_class( $classes ) {
if ( ! function_exists( 'wp_fusion' ) ) {
return $classes;
}
@verygoodplugins
verygoodplugins / wpf-daily-import.php
Created December 11, 2020 14:02
Creates a daily cron to run an Import Users operation via WP Fusion
<?php
// This runs every day and imports any new users from the connected CRM who have the specified tag ID ("123" in this example)
// If contacts with that tag already have user accounts on the site they will be skipped and no data will be loaded
// i.e. this just imports *new* users
if ( ! wp_next_scheduled( 'wpf_daily_import' ) ) {
wp_schedule_event( time(), 'daily', 'wpf_daily_import' );
}
@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-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: