Skip to content

Instantly share code, notes, and snippets.

View Lonsdale201's full-sized avatar
💭
Working

Soczó Lonsdale201

💭
Working
View GitHub Profile
@Lonsdale201
Lonsdale201 / code
Created November 5, 2024 13:48
Basic Membership for WordPress
// place the code in the child theme functions.php or a custom code snippets plugin, like FluentSnippets
// Only define the $GLOBALS with your details only
// Default global settings
$GLOBALS['membership_protected_pages'] = [25, 2, 3]; // page IDs, specify the pages that can be accessed by just logging in
$GLOBALS['membership_redirect_url'] = '/login'; // Redirect URL if logged out user try to open a protected page
$GLOBALS['membership_hide_elements'] = ['.elementor-location-header', '.xyz', '#asd']; // Classes and IDs use comma separate, this will hide (display none), from those who have not logged in
$GLOBALS['membership_hide_blog'] = true; // Hide the entire blog, blog post, and archives from not logged in users set to false to disable this function
@Lonsdale201
Lonsdale201 / code
Last active November 4, 2024 14:07
JetFormBuilder - Custom call hook - Check a specific data sum values in the form records before processing the submit
// place the code in the child theme functions.php or a custom code snippets plugin, like FluentSnippets
// What do this code
// This custom hook action checks the value of a specific meta field in JetFormBuilder records.
// It only calculates values where the given field value is greater than 0 and searches only for forms
// where the specified field exists. Additionally, it iterates only through successfully submitted forms.
// There is a predefined limit value. When a form is submitted, the system sums the values from previously successfully submitted
// forms based on the query. If the value of the submitted form is equal to or less than the limit, the form submission is allowed
// to proceed with further actions. If not, an error message is displayed with the relevant data, and the form submission is halted.
@Lonsdale201
Lonsdale201 / code
Last active November 4, 2024 15:18
JetFromBuilder - Call hook - Woo product Stock modification (like preorder)
// place the code in the child theme functions.php or a custom code snippets plugin, like FluentSnippets
// What do this code
// What this Call hook does is to extract the product identifier from the field that is filled,
// and the order quantity from the quantity field. It checks when the form is submitted
// if there is enough of the product in stock, if so, it subtracts the quantity when the form is submitted.
// If there is not enough, an error is generated and the stock of the product is not changed.
// This code does not require the JFB Add to cart add-on. The hook does not go through the checkout process,
// it only adjusts the stock of the product based on the quantity of the order the user has submitted.
@Lonsdale201
Lonsdale201 / wprocket
Created October 9, 2024 10:20
WpRocket - Lazy rendering - elementor footer issue hotfix
// place the code in the child theme functions.php or a custom code snippets plugin like FluentSnippets
// wprocket reference https://docs.wp-rocket.me/article/1835-automatic-lazy-rendering
// you can add other classes in a new line
// if saved the code run the clear the Priority Elements function (wprocket)
add_filter( 'rocket_lrc_exclusions', function( $exclusions ) {
$exclusions[] = 'elementor-location-footer';
return $exclusions;
@Lonsdale201
Lonsdale201 / code
Last active December 26, 2025 02:36
JetFormBuilder - Check ajax submit success or other status
// place the code in the child theme functions.php or a custom code snippets plugin like FluentSnippets
// if you want to handle other error statuses, change "invalid_email" to the one you want to monitor.
document.addEventListener( 'DOMContentLoaded', function() {
const { addAction } = window.JetPlugins.hooks;
addAction( 'jet.fb.observe.after', 'test/onSubmit', init );
function init( observable ) {
observable.form.submitter.status.watch( onFormSubmit );
@Lonsdale201
Lonsdale201 / unity
Last active September 22, 2024 15:22
unity - Rapid transparent Screenshot maker for prefabs and other objects
// How to use
// Create a new .cs file in the Unity with AssetPreviewScreenshot name
// Create a new folder and name it to Editor place the AssetPreviewScreenshot.cs file here!
// When done, navigate the Tools > Preview Screenshort - menu name and open it
// select your prefab material etc.. Click the Take a screenshot button
// In the preview you will see Unity in its original colour. But in the saved state it will be transparent.
// If you want to use a different color in Unity, you have to rewrite the original values in the code: #525252 (RGB value: 82, 82, 82)
// Why is colour important? Because the code explclit transforms the given colour code.
// When you look at a 3D model or material in inspector you can see what the default background color is in Unity,
@Lonsdale201
Lonsdale201 / code
Created August 17, 2024 18:17
JetEngine - Dynamic visibility - Check Url Path
// place the code in the child theme functions.php or a custom code snippets plugin.
// Open an widget, dynamic visibility, and search the Check Url Path visibility under the Custom category.
// This visibility condition function checks whether the specified text is present in the current page's URL. For example:
// example.com/test/test2
// If you specify "test2" in the visibility settings (value field), the rule will be applied whenever "test2" is found anywhere in the current page's URL.
add_action( 'jet-engine/modules/dynamic-visibility/conditions/register', function( $conditions_manager ) {
@Lonsdale201
Lonsdale201 / code
Created July 29, 2024 10:56
Dynamic coupon for wc by exit intent custom popup (beta)
// place the code in the child theme functions.php or a custom code snippets plugin, like FluentSnippets
// Define the coupon discount rate
define('COUPON_DISCOUNT_RATE', 10); // 10% discount
// Enqueue custom script for exit intent detection
function enqueue_exit_intent_script() {
if (is_cart() || is_checkout()) {
?>
@Lonsdale201
Lonsdale201 / code
Created July 27, 2024 17:58
JetEngine - Custom callback - Units converter
// place the code in the child theme functions.php or a custom code snippets plugin, like FluentSnippets
// What do this code
// This code adds a custom callback to the JetEngine built-in dynamic field widget. The callback name is: Convert Units
// The supported measurement units are: Millimeters (mm), Centimeters (cm), Meters (m), Kilometers (km), Inches (in),
Feet (ft), Yards (yd), Miles, Milliliters (ml), Deciliters (dl), Liters (l), Grams (g), Dekagrams (dkg), Kilograms (kg),
Pounds (lb), Bytes, Megabytes (MB), Gigabytes (GB), Watts (W), Kilowatts (kW), Megawatts (MW), Gigawatts (GW), Volts (V),
Kilometers per hour (km/h), Miles per hour (mph), Seconds (s), Minutes (min), Hours (h), Days (d),
Celsius (°C), Kelvin (K), Fahrenheit (°F).
@Lonsdale201
Lonsdale201 / code
Created June 25, 2024 10:52
JetFormBuilder - Call hook - Create FluentCRM List
// place the code in the child theme functions.php or a custom code snippets plugin, like FluentSnippets
// What do this code
// Using a call hook in the JetFormBuilder, if the form is submitted successfully,
// a new list is created in fluentcrm. The list name is given by the value of a text field of your choice.
// If there is already a list with this name, the hook will not be triggered, i.e. it will not be overwritten or modified.
// HOW TO USE
// Just rewrite the marked parts of the code to take the value from the text field of your choice (you need the form field name)