Skip to content

Instantly share code, notes, and snippets.

@ihslimn
ihslimn / code.php
Created April 30, 2024 19:10
JetEngine Query correct per page for Sticky Posts (not guaranteed to work with pagination)
<?php
add_filter( 'jet-engine/query-builder/query/items', function( $items, $query ) {
if ( false !== strpos( $query->name, '--sticky-correct' ) ) {
$per_page = ! empty( $query->final_query['posts_per_page'] ) ? $query->final_query['posts_per_page'] : 10;
$items = array_slice( $items, 0, $per_page );
}
return $items;
}, 0, 2 );
@ihslimn
ihslimn / code.php
Created April 24, 2024 17:43
JetReviews Remove emails from structured data
<?php
class Jet_Reviews_Rich_Snippets_Email_Remover {
private $remove_email = false;
public function __construct() {
add_action( 'elementor/frontend/widget/before_render', array( $this, 'set_remove_flag' ) );
add_filter( 'jet-reviews/user-manager/raw-user-data', array( $this, 'remove_email' ) );
}
@ihslimn
ihslimn / code.php
Created April 24, 2024 09:29
JetTabs Combined FAQ
<?php
class Jet_Tabs_Combined_Faq {
private $schema = array();
private $widget = null;
private $store = false;
public function __construct() {
add_filter( 'jet-tabs/widget/loop-items', array( $this, 'store_widget' ), 100, 3 );
@ihslimn
ihslimn / code.php
Created April 16, 2024 10:57
JetSmartFilters Get range filter min/max from CCT
<?php
add_filter( 'jet-smart-filters/range/source-callbacks', function( $callbacks ) {
$callbacks['jet_smart_filters_cct_values'] = 'Get from CCT field';
return $callbacks;
} );
add_filter( 'jet-smart-filters/filter-instance/args', function( $args ) {
@ihslimn
ihslimn / code.php
Created February 28, 2024 08:27
JetWooBuilder Show product atributes in cart
<?php
add_filter( 'get_post_metadata', function( $value, $post_id, $key ) {
if ( $key !== 'cart_product_atributes' ) {
return $value;
}
if ( ! get_post( $post_id ) ) {
return $value;
@ihslimn
ihslimn / code.html
Last active February 26, 2024 17:04
JetFormBuilder Hierarchical Select set not required levels if empty
<style>
.jet-form-builder-hr-select-level.not-required .jet-form-builder__required {
display: none;
}
</style>
<script>
jQuery( document ).ready( function( $ ) {
$( window ).on( 'jet-form-builder/after-init', initWatchers );
@ihslimn
ihslimn / code.php
Created January 3, 2024 18:59
JetSmartFilters Set default value
<?php
class JSFC_Default_Value_Shortcode {
private $defaults = array();
private $script_enqueued = false;
public function __construct() {
add_shortcode( 'jsf_default_value', array( $this, 'do_shortcode' ) );
@ihslimn
ihslimn / code.php
Last active December 29, 2023 13:47
JetSmartFilters Search for the exact value in the list
<?php
class JSF_Search_In_List {
private $prefix = 'in_list';
private $delimiter = '__';
public function __construct() {
add_filter( 'jet-smart-filters/query/final-query', array( $this, 'modify_query' ) );
add_action( 'jet-smart-filters/admin/register-dynamic-query', array( $this, 'helper_dynamic_query' ) );
@ihslimn
ihslimn / code.php
Created December 26, 2023 13:43
JetEngine JetSmartFilters CCT REST API Filter by created date
<?php
add_action( 'jet-engine/query-builder/query/after-query-setup', function( $query ) {
if ( $query->query_type !== 'rest-api' || ! is_array( $query->final_query['args'] ?? false ) ) {
return;
}
foreach ( $query->final_query['args'] as $i => $arg ) {
if ( empty( $arg['value'] ) || ! is_scalar( $arg['value'] ) || false === strpos( $arg['value'], 'macros_string::' ) ) {
@ihslimn
ihslimn / code.php
Last active December 21, 2023 13:22
JetFormBuilder Update Field addon - custom callback
<?php
function jfb_tour_get_data( $field_name, $form_id, $form_fields ) {
$args = array(
'tour_id' => $form_fields['tour_id'] ?? '',
'number_of_guests' => $form_fields['number_of_guests'] ?? '',
'date' => $form_fields['date'] ?? '',
);