Skip to content

Instantly share code, notes, and snippets.

View MjHead's full-sized avatar

Andrew Shevchenko MjHead

  • Crocoblock
  • Ukraine
View GitHub Profile
<?php
add_filter( 'jet-engine/listings/allowed-callbacks', 'jet_add_trim_callback', 10, 2 );
function jet_add_trim_callback( $callbacks ) {
$callbacks['jet_trim_string'] = 'Trim string';
return $callbacks;
}
function jet_trim_string( $string ) {
.chess-listing .jet-listing-grid__item:nth-child(even) .chess-col-1 {
order: 2;
}
.chess-listing .jet-listing-grid__item:nth-child(even) .chess-col-2 {
order: 1;
}
<?php
/**
* Testimonials start template
*/
$settings = $this->get_settings();
$data_settings = $this->generate_setting_json();
$use_comment_corner = $this->get_settings( 'use_comment_corner' );
$class_array[] = 'jet-testimonials__instance';
<?php
add_filter( 'jet-engine/listings/allowed-callbacks', 'jet_add_calc_callback', 10, 2 );
function jet_add_calc_callback( $callbacks ) {
$callbacks['jet_calc_fileds'] = 'Calculated field example';
return $callbacks;
}
function jet_calc_fileds( $field_1_value ) {
return $field_1_value * get_post_meta( get_the_ID(), 'field_2' );
<?php
add_filter( 'jet-engine/listings/allowed-callbacks', 'jet_he_add_calc_callback', 10, 2 );
function jet_he_add_calc_callback( $callbacks ) {
$callbacks['jet_he_calc_fileds'] = 'Calculated total price';
$callbacks['jet_he_calc_fileds_no_discount'] = 'Calculated total price (without discount)';
return $callbacks;
}
function jet_he_calc_fileds( $field_1_value ) {
$license_fee = absint( get_post_meta( get_the_ID(), 'license-fee', true ) );
<?php
add_filter( 'jet-abaf/db/additional-db-columns', function( $columns ) {
$columns = array(
'user_email',
'order_id'
);
return $columns;
} );
@MjHead
MjHead / jet-engine-thumbnail-title-from-related-callback.php
Last active July 18, 2019 08:23
Adds "Get thumb and title from related" callback into available callbacks list in Dynamic Field widget
<?php
add_filter( 'jet-engine/listing/grid/posts-query-args', 'je_custom_listing_order', 10, 2 );
/**
* Add multiple order by paramters to listing grid widget.
*
* What you need t replace:
* - speakers_list - replace this with your custom ID added to Listing widget
* - is-featured, speaker-name - meta fields names we need to sort by.
@MjHead
MjHead / add-parent-term-slug-into-post-url.php
Last active October 18, 2022 18:51
This code allows you to add parent term slug into single post URL
add_filter( 'register_post_type_args', 'je_change_post_type_rewrite_slug', 10, 2 );
/**
* Change post type rewirte
* Where:
* - apartments - is a post type slug. Replace is with your actual slug.
* - %locations% - is a placeholder for taxonomy term in URL.
*
* @param array $args
* @param string $post_type_name
@MjHead
MjHead / options-values-in-code.php
Last active December 21, 2024 14:42
Get option values for JetEngine options pages inside the PHP code
<?php
/**
* Method 1
* Can be used for: Any storage type
*
* page-slug - replace this with your Option Page slug
* option-name - replace this with your option Name/ID
*/
$value = jet_engine()->listings->data->get_option( 'page-slug::option-name' );