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
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 | |
/** | |
* 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
<?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 | |
/** | |
* 1. Add this code into the end of functions.php of your active theme without opening PHP tag; | |
* 2. Replace strings, metioned in the comments below, with your actual data. | |
*/ | |
add_filter( 'jet-engine/data-stores/store-post-id', function( $post_id, $store ) { | |
/** | |
* Replace 'cookies-store' with your actual Data Store 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 | |
/** | |
* 'api-request' - is a customm hook name | |
*/ | |
add_action( 'jet-form-builder/custom-action/api-request', function( $request, $action_handler ) { | |
$post_id = ! empty( $request['inserted_post_id'] ) ? $request['inserted_post_id'] : false; | |
if ( ! $post_id ) { | |
return; |
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 | |
/** | |
* Callback will be applied for each field of each CCT item in the REST API response | |
* cct_slug - change this with your actual CCT slug | |
* _cct_field_name - change this with your actual field name | |
*/ | |
add_filter( 'jet-engine/custom-content-types/rest-api/filters/cct_slug', function( $filters ) { | |
$filters['_cct_field_name'] = 'my_cct_column_filter_callback'; | |
return $filters; | |
} ); |
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/dynamic-functions/final-query', function( $query, $function_data ) { | |
$data_source = ! empty( $function_data['data_source'] ) ? $function_data['data_source'] : false; | |
$source = ! empty( $data_source['source'] ) ? $data_source['source'] : 'post_meta'; | |
$field_name = ! empty( $data['field_name'] ) ? $data['field_name'] : false; | |
if ( 'meta_value' === $source ) { | |
$query = preg_replace( '/;$/', 'AND `meta_value` != \'\';', $query ); |
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_shortcode( 'my_jet_form', 'my_jet_form_shortcode' ); | |
function my_jet_form_shortcode( $atts = array() ) { | |
$atts = shortcode_atts( array( | |
'id' => false, | |
'submit_type' => 'reload', // or ajax | |
'required_mark' => '*', |
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 | |
/** | |
* JetEngine CCT-related API functions to use in theme or plugin | |
* | |
* Theme usage - include get_theme_file_path( 'jet-engine-cct-api.php' ); | |
* Plugin usage - include PLUGIN_PATH . 'path-to-file-inside-plugin/jet-engine-cct-api.php'; | |
*/ | |
/** |