This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Given example can be used to format timestamp into human-readable date, but the same logic can be used for any modifications | |
*/ | |
add_filter( 'jet-engine/admin-filters/filter-label', function( $label, $filter ) { | |
if ( 'meta' === $filter['type'] && '__date' === $filter['meta_key'] ) { | |
$label = date_i18n( get_option( 'date_format' ), $label ); | |
} | |
return $label; | |
}, 10, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Allows to update required CCT items on change posts in selected user meta data store | |
*/ | |
add_filter( 'jet-engine/data-stores/ajax-store-fragments', function( $fragments, $store ) { | |
// Replace 'quoted-list' with your actual Data Store slug | |
$my_store = 'quoted-list'; | |
// Replace 'users_wishlist' with you actual CCT slug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'init', function() { | |
// replace your-post-type-slug and your-meta-field-name with your actual data | |
register_post_meta( 'your-post-type-slug', 'your-meta-field-name', array( | |
'single' => true, | |
'type' => 'string', | |
'default' => '', | |
'auth_callback' => '__return_true', | |
'show_in_rest' => true, | |
) ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_ajax_jet_ajax_search', 'my_get_search_results', 0 ); | |
add_action( 'wp_ajax_nopriv_jet_ajax_search', 'my_get_search_results', 0 ); | |
function my_get_search_results() { | |
$request = $_GET['data']; | |
$search_query = urldecode( $request['value'] ); | |
$per_page = ( int ) $request['limit_query_in_result_area']; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Note! Always include mcros file only on 'jet-engine/register-macros' hook - before base class is not avaialable, | |
* after - all macros already registered and you can't insert a new one. | |
*/ | |
add_action( 'jet-engine/register-macros', function() { | |
require_once get_theme_file_path( 'macros.php' ); | |
new My_JE_Macros(); | |
} ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'jet-engine/listing/grid/posts-query-args', function( $args, $widget, $settings ) { | |
if ( 'custom-query' === $settings['_css_classes'] ) { | |
$args['meta_query'][] = array( | |
'relation' => 'OR', | |
0 => array( | |
'key' => 'submission-date', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Adds custom fields into the insert new related item popup. | |
* Hook name - jet-engine/relations/types/posts/create-fields - depends on type of created item, | |
* for CPT it will be - jet-engine/relations/types/posts/create-fields | |
* for terms - jet-engine/relations/types/terms/create-fields | |
* for users - jet-engine/relations/types/mix/create-fields/users | |
* | |
* just replace 'jobs' in the example with your actual post type/taxonomy slug |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get fields for the given context and object | |
* Should be called on hook 'init' with priority 11 or later | |
*/ | |
// Fields for Post post type | |
$post_fields = jet_engine()->meta_boxes->get_fields_for_context( 'post_type', 'post' ); | |
// Fields for Product post type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Update related item from form action/notification | |
* | |
* @param array $args [description] | |
* @return [type] [description] | |
*/ | |
function my_update_related_items( $args = array() ) { | |
$relation = ! empty( $args['relation'] ) ? $args['relation'] : false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'jet-engine/listings/ajax-listing-url', function( $url ) { | |
return esc_url( admin_url( 'admin-ajax.php' ) ); | |
} ); |