Skip to content

Instantly share code, notes, and snippets.

View jack-arturo's full-sized avatar

Jack Arturo jack-arturo

View GitHub Profile
@jack-arturo
jack-arturo / 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;
}
@jack-arturo
jack-arturo / 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 . ')';
}
}
@jack-arturo
jack-arturo / 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 ) {
@jack-arturo
jack-arturo / queryWooCommerce.py
Last active July 29, 2024 04:37
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/"
@jack-arturo
jack-arturo / 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.
*/
@jack-arturo
jack-arturo / my-plugin.php
Created December 8, 2022 11:38
WordPress plugin created by ChatGPT (https://i.wpfusion.com/8p22pV)
<?php
// Define a class for our plugin
class MyPlugin {
// Define a static property to hold the single instance of the class
private static $instance;
// Define a private constructor to prevent the class from being instantiated directly
private function __construct() {
// Add the admin settings page to the WordPress admin menu
@jack-arturo
jack-arturo / wpf-lock-user-for-webhooks.php
Last active March 8, 2023 11:45
Blocks incoming webhooks for a user for one minute after tags were applied to them (to prevent loopbacks)
<?php
/**
* Sets a transient to lock a user from receiving webhooks from the CRM for one minute
* after tags have been applied by WP Fusion.
*
* @param int $user_id The user ID.
*/
function wpf_lock_user( $user_id ) {
@jack-arturo
jack-arturo / copy-memberium-auto-enroll-tags.php
Last active December 6, 2022 10:55
Copies Memberium's LearnDash auto-enroll tags over to WP Fusion's Link With Tag setting
<?php
function maybe_migrate_auto_enroll_tags() {
// visit /wp-admin/index.php?migrate=true to start.
if ( isset( $_GET['migrate'] ) ) {
$linked_courses = get_posts(
array(
@jack-arturo
jack-arturo / inherit-memberium-access-rules.php
Last active December 7, 2022 10:48
Makes WP Fusion inherit post access rules and redirects that were created in Memberium
<?php
function inherit_memberium_access_rules( $settings, $post_id ) {
if ( is_object( $post_id ) ) {
$post_id = $post_id->ID; // wpf_settings_for_meta_box passes a WP_Post.
}
if ( empty( $settings['allow_tags'] ) ) {
@jack-arturo
jack-arturo / edd-custom-cancel.php
Created November 1, 2022 09:59
Modifies the Easy Digital Downloads cancellation link to point to a custom "Confirm cancellation" page
<?php
/**
* Modify the EDD cancel URL to point custom cancellation page.
*
* @param string $url The cancel URL.
* @param EDD_Subscription $subscription The subscription.
*/
function wpf_edd_subscription_cancel_url( $url, $subscription ) {