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 July 12, 2024 15:09
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;
@Crocoblock
Crocoblock / jet-engine-fix-oembed-component-vars.php
Last active May 24, 2024 11:54
JetEngine. Components. Replace CSS vars from component properties with raw color values of these properties in oEmbed URLs
<?php
add_action( 'jet-engine/component/before-content', function( $component ) {
add_filter( 'oembed_result', 'jet_components_fix_oembed_vars', 99 );
} );
add_action( 'jet-engine/component/after-content', function() {
remove_filter( 'oembed_result', 'jet_components_fix_oembed_vars', 99 );
} );
function jet_components_fix_oembed_vars( $html ) {
@Crocoblock
Crocoblock / code.php
Created May 23, 2024 20:42
JetFormBuilder JetEngine Get coordinates from map autocomplete field and store to user
<?php
add_action( 'jet-form-builder/custom-action/update-user-address', function( $request ) {
if ( ! function_exists( 'jet_engine' ) ) {
return;
}
if ( empty( $request['user_id'] ) ) {
return;
@Crocoblock
Crocoblock / code.php
Created May 22, 2024 08:00
JetEngine unslash values before storing a CCT item
<?php
add_filter( 'jet-engine/custom-content-types/update-item/sanitize-field-value', function( $value, $field_name, $field ) {
if ( ! is_string( $value ) ) {
return $value;
}
if ( empty( $field['type'] ) || ! in_array( $field['type'], array( 'text', 'textarea' ) ) ) {
return $value;
}
@Crocoblock
Crocoblock / code.js
Last active May 21, 2024 15:34
JetFormBuilder Map field set coordinates and zoom level programmatically
//assuming the ID of the form is 1709, and map field name if 'map1'
const formId = 1709;
const mapFieldName = 'map1';
const observable = JetFormBuilder[ formId ];
const mapField = observable.getInput( mapFieldName );
@Crocoblock
Crocoblock / code.php
Created May 15, 2024 08:59
JetEngine restrict autocomplete to certain countries
<?php
//Google maps
add_filter( 'jet-engine/maps-listings/autocomplete-url-args/google', function($args){
$args['components'] = 'country:de|country:at|country:ch';
return $args;
} );
//Openstreetmaps