Skip to content

Instantly share code, notes, and snippets.

View Crocoblock's full-sized avatar

Crocoblock Crocoblock

View GitHub Profile
@Crocoblock
Crocoblock / code.php
Last active September 25, 2024 19:51
JetEngine QR code macro for Dynamic Link label
<?php
class JetEngineDlUrlSaver {
private $url = '';
private static $instance = null;
private function __construct() {
add_filter( 'jet-engine/listings/dynamic-link/pre-render-link', array( $this, 'store_url' ), 100000, 4 );
}
@Crocoblock
Crocoblock / jet-engine-macros-shortcode.php
Last active March 2, 2025 16:12
Register [jet_engine_macros] shortcode to use JetEngine macros anywhere
<?php
/**
* How to use:
* 1. Add this code to your website with any code snippets plugin or into functions.php of your active theme.
* 2. In your admin area go to JetEngine/Macros Generator, generate and copy macros you need.
* 3. Use this macros anywhere with shortcode in following format: [jet_engine_macros macros="%generated_macros%"]
*
* Real world example:
* [jet_engine_macros macros="%jet_engine_field_name|event_date|field_value%"]
*/
@Crocoblock
Crocoblock / code.php
Created September 19, 2024 17:46
JetFormBuilder Change form action URL
<?php
add_filter( 'jet-form-builder/form-action-url', function( $url ) {
$form_id = ( int ) ( jet_fb_live()->form_id ?? 0 );
if ( $form_id === 12598 ) {
return 'https://google.com';
}
return $url;
@Crocoblock
Crocoblock / code.php
Created August 28, 2024 11:26
JetEngine Output component with PHP
<?php
class JE_Component_Shortcode {
public function __construct() {
add_action( 'init', array( $this, 'init' ), 100 );
}
public function init() {
if ( ! function_exists( 'jet_engine' ) ) {
@Crocoblock
Crocoblock / megamenu_overlay.js
Created August 28, 2024 11:20
JavaScript code to add overlay functionality to mega menu items on a web page. When you hover over each menu item, an overlay is displayed behind it, providing a lightbox effect
document.addEventListener("DOMContentLoaded", function () {
// Create an overlay for each mega menu item
const megaMenuItems = document.querySelectorAll(".jet-mega-menu-item");
megaMenuItems.forEach(function (megaMenuItem) {
const overlay = document.createElement("div");
overlay.className = "overlay";
megaMenuItem.appendChild(overlay); // Append the overlay to the menu item
megaMenuItem.addEventListener("mouseenter", function () {
@Crocoblock
Crocoblock / code.php
Last active October 23, 2024 11:07
JetFormBuilder currency mask
<?php
class JFB_Currency_Mask {
private $processed = false;
public function __construct() {
add_filter( 'jet-form-builder/render/text-field/attributes', array( $this, 'process_fields' ), 10, 2 );
}
@Crocoblock
Crocoblock / code.php
Created June 25, 2024 10:35
JetEngine Slim SEO compatibility
<?php
add_filter( 'slim_seo_bricks_skipped_elements', function( $elements ) {
$elements[] = 'jet-engine-listing-grid';
return $elements;
} );
@Crocoblock
Crocoblock / code.php
Last active July 2, 2024 14:49
JetEngine Break listing alphabetically load more / pagination compatibility / Terms Query compatibility
<?php
class JBBP_Terms_Fix {
public function __construct() {
add_filter( 'jet-engine/listing/render/default-settings', array( $this, 'default_settings' ) );
add_filter( 'jet-engine/listing/grid/nav-widget-settings', array( $this, 'nav_settings' ), 10, 2 );
add_filter( 'jet-engine-break-alphabetically/prev-post', array( $this, 'prev_term' ), 100, 3 );
}
@Crocoblock
Crocoblock / code.php
Created June 18, 2024 09:42
JetFormBuilder fix refer in ajax popup
<?php
add_filter( 'jet-form-builder/form-refer-url', function ( $refer ) {
if ( empty( $_POST['action'] ) || $_POST['action'] !== 'jet_popup_get_content' ) {
return $refer;
}
$url = $_POST['data']['page_url'] ?? '';
if ( empty( $url ) ) {
@Crocoblock
Crocoblock / code.html
Created May 28, 2024 15:35
JetFormBuilder Unselectable radio
<script>
document.addEventListener( 'DOMContentLoaded', function() {
if ( ! window?.JetPlugins?.hooks ) {
return;
}
const {
addAction,
} = window.JetPlugins.hooks;