Skip to content

Instantly share code, notes, and snippets.

@ihslimn
ihslimn / macro.php
Last active March 31, 2022 14:18
Get related items by "Sibling" Relation
add_filter( 'jet-engine/listings/macros-list', 'register_get_related_items_by_sibling_relation_macro' );
function register_get_related_items_by_sibling_relation_macro( $macros_list ) {
$macros_list['rel_get_items_by_relation'] = array(
'label' => 'Related Items By Sibling Relation',
'cb' => '__get_related_items_by_sibling_relation',
'args' => array(
'_rel_id' => array(
'label' => __( 'From Relation', 'jet-engine' ),
@ihslimn
ihslimn / wc-cross-sells-macro.php
Last active December 4, 2023 11:38
wc-cross-sells-macro.php
<?php
add_action( 'jet-engine/register-macros', function(){
if ( ! function_exists( 'WC' ) ) {
return;
}
class WC_Cross_Sale_Macro extends \Jet_Engine_Base_Macros {
@ihslimn
ihslimn / gist:aeb76a778ed44d32faf640f4d3bda8ea
Created May 6, 2022 13:52
Get properties from query macro
//add Get properties from query macro
add_filter( 'jet-engine/listings/macros-list', 'register_query_items_macro' );
function register_query_items_macro( $macros_list ) {
$macros_list['get_props_from_query'] = array(
'label' => 'Get properties from query',
'cb' => 'get_props_from_query_macro',
'args' => array(
'query_id' => array(
add_filter( 'jet-engine/listings/macros-list', 'register_current_post_parent_macro' );
function register_current_post_parent_macro( $macros_list ) {
$macros_list['current_post_parent'] = array(
'label' => 'Current post parent (current post ID if no parent)',
'cb' => '_get_current_post_parent',
);
return $macros_list;
@ihslimn
ihslimn / gist:e953cf7e848e01ef06c66bfda26b42b7
Last active December 15, 2023 21:05
Format date string macro
add_filter( 'jet-engine/listings/macros-list', 'register_format_date_string_macro' );
function register_format_date_string_macro( $macros_list ) {
$macros_list['format_date'] = array(
'label' => 'Format date string',
'cb' => '_get_format_date_string',
'args' => array( 'format' => array(
'label' => 'Format',
'type' => 'text',
@ihslimn
ihslimn / JE_Query_Filter_Options_Generator.php
Last active October 7, 2022 11:50
JE_Query_Filter_Options_Generator
<?php
class JE_Query_Filter_Options_Generator {
public function __construct() {
add_action( 'plugins_loaded', array( $this, 'maybe_add_filters' ) );
}
public function maybe_add_filters() {
@ihslimn
ihslimn / ajax-handler.php
Last active October 6, 2022 13:50
convert CCT to CPT
<?php
add_action( 'wp_ajax_cycle_through_cct_to_clone', 'cycle_through_cct_to_clone' );
function cycle_through_cct_to_clone() {
$type_object = Jet_Engine\Modules\Custom_Content_Types\Module::instance()->manager->get_content_types( 'blum_cct' );
$handler = $type_object->get_item_handler();
$query = Jet_Engine\Query_Builder\Manager::instance()->get_query_by_id( 196 );
@ihslimn
ihslimn / fix-menu-form.php
Created November 8, 2022 11:41
JetMenu Fix JetFormBuilder form in menu
<?php
class JFB_Fix_Action_URL {
public function __construct() {
add_filter( 'jet-form-builder/form-action-url', array( $this, 'store_action_url' ), -999 );
add_filter( 'jet-form-builder/form-refer-url', array( $this, 'store_referer_url' ), -999 );
add_action( 'wp_head', array( $this, 'print_inline_script' ) );
}
@ihslimn
ihslimn / convert-id-list.php
Created November 8, 2022 16:38
JetFormBuilder Convert post ID list to post title list
<?php
add_action(
'jet-form-builder/form-handler/before-send',
function ( \Jet_Form_Builder\Form_Handler $form_handler ) {
$action_handler = $form_handler->action_handler;
@ihslimn
ihslimn / slider-loop-start.php
Last active November 11, 2022 06:31
JetElements Allow set ID for slider
<?php
/**
* Slider start template
*/
$settings = $this->get_settings_for_display();
$class_array[] = 'jet-slider__items';
$class_array[] = 'sp-slides';
$classes = implode( ' ', $class_array );