Skip to content

Instantly share code, notes, and snippets.

@liranop
liranop / modify taxomony slug
Created October 6, 2022 17:00
change taxonomy url to domain/base_url/parent-term/child-term
function modify_taxonomy() {
// get the arguments of the already-registered taxonomy
$taxonomy = 'taxonomy_name';
$cpt_type = array( 'post' , 'gallery');
$base_url = 'blog';
$category_args = get_taxonomy( $taxonomy ); // returns an object
$category_args->show_admin_column = true;
$category_args->query_var = true;
@liranop
liranop / expend shipping row
Last active August 11, 2023 05:58
Make shipping row in woocommerce cart and checkout to full width
/**
* @snippet Expend WooCommerce Shipping Row in Cart and Checkout
*/
add_action( 'wp_footer', 'expend_shipping_row_jscript', 9999 );
function expend_shipping_row_jscript() {
if ( is_cart() || is_checkout() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) ) {
?>
<script type="text/javascript">
//
// https://developers.elementor.com/docs/hooks/custom-query-filter/
//
function custom_get_related_events($query) {
global $post;
// Get the custom field value for the current post
$meta_field = get_post_meta($post->ID, 'meta_field_name', true);
// CHANGE 'meta_field_name' !!!!!! to your relationship filed's name
@liranop
liranop / gist:23b0525475f66ed1fbfedc3a661ce0ab
Last active September 19, 2023 10:46
numeric duration callback to literal (dynamic field widget - elementor + jetengine)
add_filter( 'jet-engine/listings/allowed-callbacks', 'jet_custom_callbacks' );
/**
* Add callback to list.
*/
function jet_custom_callbacks( $callbacks ) {
$callbacks['jet_number_to_duration'] = __( 'Number to duration', 'txt-domain' );
return $callbacks;
@liranop
liranop / add select2 to jetsmartfilter select
Last active January 19, 2024 10:04
add select2 to jetsmartfilter select (php code snippet + js script)
<script>
(function() {
jQuery(document).on('jet-smart-filters/inited', function( initEvent ) {
// Initialize select2 on the select field
jQuery('.jet-select__control').select2({
placeholder: 'Search...',
width: '100%',
@liranop
liranop / upload media field - hide empty media box
Last active January 29, 2024 04:44
JetFormBuilder & media field - hide empty space above the input when no selected file
<script>
document.addEventListener("DOMContentLoaded", function () {
const fileInputs = document.querySelectorAll(".jet-form-builder-file-upload__input");
function toggleFileContentVisibility(fileContainer) {
const fileContent = fileContainer.querySelector(".jet-form-builder-file-upload__content");
const files = fileContainer.querySelectorAll(".jet-form-builder-file-upload__files .jet-form-builder-file-upload__file");
if (files.length < 1) {
fileContent.style.display = "none";
<ul class="tab-steps--list"></ul>
<script>
jQuery(document).ready(function() {
let isDragging = false;
const tabStepsList = jQuery('.tab-steps--list');
function startDrag() {
isDragging = true;
tabStepsList.addClass('dragg');
}
<ul class="tab-steps--list"></ul>
<script>
jQuery(document).ready(function() {
let isDragging = false;
const tabStepsList = jQuery('.tab-steps--list');
function startDrag() {
isDragging = true;
tabStepsList.addClass('dragg');
}
@liranop
liranop / AutoApply JetEngine Date Range
Last active January 30, 2024 15:47
AutoApply JetEngine Date Range (+ hide apply button) 0 do not hide the apply button on settings!
<script>
jQuery(document).ready(function($) {
// Select the input fields and apply button
var fromDateInput = jQuery('.jet-date-range__from');
var toDateInput = jQuery('.jet-date-range__to');
var applyButton = jQuery('.jet-date-range__submit');
applyButton.hide();
// Attach event listener for 'input' on the "from" date field