<?php // Exit if accessed directly if ( !defined( 'ABSPATH' ) ) exit; // BEGIN ENQUEUE PARENT ACTION // AUTO GENERATED - Do not modify or remove comment markers above or below: if ( !function_exists( 'chld_thm_cfg_locale_css' ) ): function chld_thm_cfg_locale_css( $uri ){ if ( empty( $uri ) && is_rtl() && file_exists( get_template_directory() . '/rtl.css' ) ) $uri = get_template_directory_uri() . '/rtl.css'; return $uri; } endif; add_filter( 'locale_stylesheet_uri', 'chld_thm_cfg_locale_css' ); if ( !function_exists( 'child_theme_configurator_css' ) ): function child_theme_configurator_css() { wp_enqueue_style( 'chld_thm_cfg_child', trailingslashit( get_stylesheet_directory_uri() ) . 'style.css', array( ) ); wp_enqueue_style( 'home_new', get_stylesheet_directory_uri(). '/css/home_new.css?'.time() ); } endif; add_action( 'wp_enqueue_scripts', 'child_theme_configurator_css', 10 ); // END ENQUEUE PARENT ACTION function enqueue_custom_scripts() { wp_enqueue_script('jquery'); wp_enqueue_script('custom-scripts', get_stylesheet_directory_uri() . '/js/custom-scripts.js?'.time(), array('jquery'), '1.0', true); wp_localize_script('custom-scripts', 'my_ajax_object', array('ajaxurl' => admin_url('admin-ajax.php'))); } add_action('wp_enqueue_scripts', 'enqueue_custom_scripts'); add_shortcode('custom_product_list','custom_product_list_shortcode_function'); function custom_product_list_shortcode_function(){ ob_start(); $args = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => '12' ); $products = new WP_Query($args); ?> <div id="product-list-container"> <?php if ($products->have_posts()) : while ($products->have_posts()) : $products->the_post(); $attachment_id = get_post_thumbnail_id($products->get_id()); $image_url = wp_get_attachment_url($attachment_id); if(empty($image_url)){ $default_product_image_id = get_option('woocommerce_placeholder_image'); $image_url = wp_get_attachment_url($default_product_image_id); } ?> <div class="product_item"> <div class="prod_image"> <img src="<?php echo $image_url; ?>"> </div> <div class="product-content"> <div class="prod_title"> <h2><?php echo the_title(); ?></h2> </div> <div class="chassis"> <div class="chassis_icon"> </div> <div class="chassis_size"> <?php the_field('chassis',get_the_ID()); ?> </div> </div> <div class="weight"> <div class="weight_icon"> <?php the_field('weight_tonne',get_the_ID()); ?> </div> <div class="weight_tonne"> </div> </div> <div class="learn_more"> <a class="learn_more" href="<?php the_permalink(get_the_ID()); ?>">Learn More</a> </div> </div> </div> <?php endwhile; endif; ?> </div> <button id="load-more-button" total_page="<?php echo $products->max_num_pages; ?>">Load More</button> <?php return ob_get_clean(); } function load_more_function() { $page = $_POST['page']; $posts_per_page = 12; // Adjust the number of products per page $args = array( 'post_type' => 'product', // Adjust to your custom post type 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, 'paged' => $page, ); $query = new WP_Query($args); if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); $attachment_id = get_post_thumbnail_id($query->get_id()); $image_url = wp_get_attachment_url($attachment_id); if(empty($image_url)){ $default_product_image_id = get_option('woocommerce_placeholder_image'); $image_url = wp_get_attachment_url($default_product_image_id); } ?> <div class="product_item"> <div class="prod_image"> <img src="<?php echo $image_url; ?>"> </div> <div class="product-content"> <div class="prod_title"> <h2><?php echo the_title(); ?></h2> </div> <div class="chassis"> <div class="chassis_icon"> </div> <div class="chassis_size"> <?php the_field('chassis',get_the_ID()); ?> </div> </div> <div class="weight"> <div class="weight_icon"> <?php the_field('weight_tonne',get_the_ID()); ?> </div> <div class="weight_tonne"> </div> </div> <div class="learn_more"> <a class="learn_more" href="<?php the_permalink(get_the_ID()); ?>">Learn More</a> </div> </div> </div> <?php endwhile; endif; wp_die(); } add_action('wp_ajax_load_more_action', 'load_more_function'); add_action('wp_ajax_nopriv_load_more_action', 'load_more_function'); // Custom shortcode for related products based on current category function related_products_shortcode($atts) { ob_start(); $current_product_id = get_the_ID(); $cats_array = array(0); $terms = wp_get_post_terms( $current_product_id, 'product_cat' ); foreach ( $terms as $term ) { $children = get_term_children( $term->term_id, 'product_cat' ); if ( !sizeof( $children ) ) $cats_array[] = $term->term_id; } $args = array( 'post_type' => 'product', 'post__not_in' => array( $current_product_id ), // exclude current product 'ignore_sticky_posts' => 1, 'no_found_rows' => 1, 'posts_per_page' => 4, //'orderby' => $orderby, 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $cats_array ), ) ); $products = new WP_Query( $args ); if ( $products->have_posts() ) : while ( $products->have_posts() ) : $products->the_post(); $attachment_id = get_post_thumbnail_id($products->get_id()); $image_url = wp_get_attachment_url($attachment_id); if(empty($image_url)){ $default_product_image_id = get_option('woocommerce_placeholder_image'); $image_url = wp_get_attachment_url($default_product_image_id); } ?> <div class="product_item"> <div class="prod_image"> <img src="<?php echo $image_url; ?>"> </div> <div class="product-content"> <div class="prod_title"> <h2><?php echo the_title(); ?></h2> </div> <div class="chassis"> <div class="chassis_icon"> </div> <div class="chassis_size"> <?php the_field('chassis',get_the_ID()); ?> </div> </div> <div class="weight"> <div class="weight_icon"> <?php the_field('weight_tonne',get_the_ID()); ?> </div> <div class="weight_tonne"> </div> </div> <div class="learn_more"> <a class="learn_more" href="<?php the_permalink(get_the_ID()); ?>">Learn More</a> </div> </div> </div> <?php endwhile; endif; wp_reset_postdata(); return ob_get_clean(); } add_shortcode('custom_related_products', 'related_products_shortcode'); function remove_variations_form_single_product() { remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30); add_action('woocommerce_after_single_product_summary', 'woocommerce_template_single_add_to_cart', 5); } add_action('wp', 'remove_variations_form_single_product'); add_action('woocommerce_after_single_product_summary', 'custom_section', 5); function custom_section(){ global $post; echo '<div class="custom-section">'; } add_action('woocommerce_after_single_product_summary', 'custom_productVideo', 6); function custom_productVideo(){ global $post; $videoUrl = get_field('product_video', $post->ID); $videoImgUrl = get_field('product_video_image', $post->ID); if (!empty($videoUrl)) { ?> <div class="product-video"> <h3>Product Walkthrough</h3> <div class="video-container" id="videoContainer"> <img src="<?php echo $videoImgUrl['url']; ?>" alt="videoImg" id="videoImg"> <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/ic-play.svg" alt="Play Button" class="play-icon" id="playIcon"> </div> <script> document.getElementById("videoContainer").addEventListener("click", function() { var videoContainer = document.getElementById("videoContainer"); var videoURL = "<?php echo $videoUrl['url']; ?>"; videoContainer.innerHTML = '<iframe width="560" height="315" src="' + videoURL + '" frameborder="0" allowfullscreen></iframe>'; }); </script> </div> <?php } ?> </div> <div style="clear:both;"></div> <?php } function chases_banner_data_shortcode(){ $product_id = get_the_ID(); $chasis = get_post_meta($product_id, 'chassis', true); echo '<p style="text-align: center;">' . $chasis . '</p>'; } function weight_banner_data_shortcode(){ $product_id = get_the_ID(); $chasis = get_post_meta($product_id, 'weight_tonne', true); echo '<p style="text-align: center;">' . $chasis . '</p>'; } function axle_banner_data_shortcode(){ $product_id = get_the_ID(); $chasis = get_post_meta($product_id, 'axle', true); echo '<p style="text-align: center;">' . $chasis . '</p>'; } function brakes_banner_data_shortcode(){ $product_id = get_the_ID(); $chasis = get_post_meta($product_id, 'brakes', true); echo '<p style="text-align: center;">' . $chasis . '</p>'; } add_shortcode('chases_banner_data', 'chases_banner_data_shortcode'); add_shortcode('weight_banner_data', 'weight_banner_data_shortcode'); add_shortcode('axle_banner_data', 'axle_banner_data_shortcode'); add_shortcode('brakes_banner_data', 'brakes_banner_data_shortcode'); // Remove default WooCommerce breadcrumbs function custom_remove_woocommerce_breadcrumbs() { if (is_product_category()) { remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20); add_action('woocommerce_before_shop_loop', 'woocommerce_breadcrumb', 5); remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20); remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30); } } add_action('template_redirect', 'custom_remove_woocommerce_breadcrumbs'); function add_other_product_info_category_page(){ if (is_product_category()) { global $product; // Get the custom field value $chassis = get_field('chassis', $product->get_id()); $weight_tonne = get_field('weight_tonne', $product->get_id()); // Display the custom field value if it exists if ($chassis) { echo '<div class="chassis-field"> <i class="chassis-icon"></i> <span class="chass-value">' . esc_html($chassis) . '</span> </div>'; } if ($weight_tonne) { echo '<div class="weight-field"> <i class="weight-icon"></i> <span class="weight-value">' . esc_html($weight_tonne) . '</span> </div>'; } } } add_action('woocommerce_shop_loop_item_title', 'add_other_product_info_category_page', 20); function custom_variable_product_button_text_in_category( $button_text, $product ) { if ( is_product_category() && $product->is_type( 'variable' ) ) { $button_text = 'Learn More'; // Replace with your custom text } return $button_text; } add_filter( 'woocommerce_product_add_to_cart_text', 'custom_variable_product_button_text_in_category', 10, 2 ); // Shop and category pages /** * UTFA: Live Price Display + Request Formal Quote * Product pages: shows running total, updates with accessories, pre-fills enquiry form. */ function utfa_product_quote_script() { if ( ! is_product() ) return; ?> <script> jQuery(function($) { if (!$('body').hasClass('single-product')) return; var productName = $('.product_title').first().text().replace(/\s+/g,' ').trim(); var basePrice = 0; // Build the price bar + RFQ button and insert above the old Enquire button var $bar = $('<div id="utfa-rfq-bar" style="order:4;order:4;margin:24px 0 20px;padding:18px 22px;background:#1a1a1a;border:2px solid #42FFF9;border-radius:4px;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:14px;">' + '<div>' + '<div style="color:rgba(255,255,255,0.55);font-size:11px;text-transform:uppercase;letter-spacing:1.5px;margin-bottom:6px;">Total Price (excl. GST &amp; on-road)</div>' + '<div id="utfa-total-price" style="color:#42FFF9;font-size:34px;font-weight:700;line-height:1;">Choose your state</div>' + '</div>' + '<a href="#" class="enquire_btn popmake-1230 pum-trigger" id="utfa-rfq-btn" style="background:#42FFF9;color:#111;font-weight:800;padding:15px 30px;font-size:14px;text-decoration:none;border-radius:3px;white-space:nowrap;text-transform:uppercase;letter-spacing:1.5px;display:inline-block;">Request Formal Quote</a>' + '</div>'); // Insert before the existing ENQUIRE button wrapper, then hide the original var $oldBtn = $('.enquire_btn.popmake-1230').not('#utfa-rfq-btn'); if ($oldBtn.length) { $oldBtn.closest('p,.wp-block-paragraph,.enquire-wrap,div').first().before($bar).hide(); } else { $('input[type="checkbox"][data-price]').last().closest('table,ul,div').after($bar); } function addonsTotal() { var t = 0; $('input[type="checkbox"][data-price]:checked').each(function(){ t += parseFloat($(this).data('price')) || 0; }); return t; } function fmtPrice(n) { return '$' + parseFloat(n).toLocaleString('en-AU',{minimumFractionDigits:2,maximumFractionDigits:2}); } function refreshPrice() { if (basePrice > 0) { $('#utfa-total-price').text(fmtPrice(basePrice + addonsTotal())); } } $('form.variations_form') .on('found_variation', function(e,v){ basePrice = parseFloat(v.display_price) || 0; refreshPrice(); }) .on('reset_data', function(){ basePrice = 0; $('#utfa-total-price').text('Choose your state'); }); $(document).on('change','input[type="checkbox"][data-price]', refreshPrice); // Pre-fill Gravity Form when Popup Maker popup opens $(document).on('pumAfterOpen', function(){ var state = $('select[name="attribute_pa_location"] option:selected').text(); if (!state || /choose/i.test(state)) state = 'Not yet selected'; var addons = []; $('input[type="checkbox"][data-price]:checked').each(function(){ addons.push('- ' + $(this).val() + ' (+' + fmtPrice(parseFloat($(this).data('price'))) + ')'); }); var totalStr = basePrice > 0 ? fmtPrice(basePrice + addonsTotal()) + ' (excl. GST & on-road costs)' : 'State not yet selected'; var msg = 'Product: ' + productName + '\n' + 'State: ' + state + '\n' + (addons.length ? 'Accessories:\n' + addons.join('\n') + '\n' : '') + 'Quoted Total: ' + totalStr; $('#input_1_7').val(msg).trigger('input'); }); }); </script> <?php } add_action('wp_footer','utfa_product_quote_script'); /** * RFQ bar for skip-bin-trailers and agency-trailers * Uses DOMContentLoaded so it runs after deferred jQuery loads */ function utfa_new_cat_rfq_bar_fix() { if ( ! is_product() ) return; if ( ! has_term( array( 'skip-bin-trailers', 'agency-trailers', 'box-trailers' ), 'product_cat' ) ) return; ?> <style>#utfa-rfq-bar{order:4!important;}</style> <script> document.addEventListener('DOMContentLoaded', function() { var $ = jQuery; var $varWrap = $('.single_variation_wrap'); var isSimple = ! $varWrap.length; var $existing = $('#utfa-rfq-bar'); if ( $existing.length ) { if ( $existing.closest('.single_variation_wrap').length ) { if (!isSimple) { $varWrap.before($existing); $varWrap.find('.enquire_btn.popmake-1230').hide(); } } return; } var productName = $('.product_title').first().text().replace(/\s+/g,' ').trim(); var $bar = $('<div id="utfa-rfq-bar" style="margin:24px 0 20px;padding:18px 22px;background:#1a1a1a;border:2px solid #42FFF9;border-radius:4px;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:14px;"><div style="display:flex;flex-direction:column;gap:6px;"><div style="color:rgba(255,255,255,0.55);font-size:11px;text-transform:uppercase;letter-spacing:1.5px;margin-bottom:6px;">Total Price (excl. GST &amp; on-road)<\/div><div id="utfa-total-price" style="color:#42FFF9;font-size:34px;font-weight:700;line-height:1;">Choose your state<\/div><\/div><a href="#" id="utfa-rfq-btn" class="enquire_btn popmake-1230 pum-trigger button" style="background:#42FFF9;color:#111;font-weight:800;padding:15px 30px;font-size:14px;text-decoration:none;border-radius:3px;">Request Formal Quote<\/a><\/div>'); // Insert bar after the product description blurb var $shortDesc = $('.woocommerce-product-details__short-description'); if ($shortDesc.length) { $shortDesc.after($bar); } else { $varWrap.before($bar); } if (!isSimple) { $varWrap.find('.enquire_btn.popmake-1230').hide(); } // Hide the add-to-cart quantity section (replaced by RFQ bar) if (!isSimple) { $('.woocommerce-variation-add-to-cart').hide(); // Move the Location dropdown and pricing note near the bar $('.variations').insertBefore($bar).css('order', '4'); $('.woocommerce-variation-price.custom_variation').hide(); } var currentPrice = 0; if (!isSimple) $('form.variations_form').on('found_variation', function(e, variation) { currentPrice = parseFloat(variation.display_price) || 0; if (currentPrice > 0) { $('#utfa-total-price').text('$' + currentPrice.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',')); } }).on('reset_data', function() { currentPrice = 0; $('#utfa-total-price').text('Choose your state'); }); $(document).on('pumAfterOpen', function() { var state = $('select[name="attribute_pa_location"] option:selected').text(); if (/choose/i.test(state)) state = ''; var totalStr = currentPrice > 0 ? '$' + currentPrice.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',') : ''; var msg = 'Product: ' + productName + '\n' + (state ? 'Location: ' + state + '\n' : '') + (totalStr ? 'Quoted Total: ' + totalStr : ''); $('#input_1_7').val(msg).trigger('input'); }); }); </script> <?php } add_action( 'wp_footer', 'utfa_new_cat_rfq_bar_fix', 99 ); /** * Hide "CURRENTLY UNDER CONSTRUCTION" banner on skip-bin and agency trailer pages */ function utfa_hide_construction_banner() { if ( ! is_product() ) return; if ( ! has_term( array( 'skip-bin-trailers', 'agency-trailers' ), 'product_cat' ) ) return; echo '<style>.product-details-section::before{display:none!important;}.product-details-section{padding-top:0!important;}</style>'; } add_action( 'wp_head', 'utfa_hide_construction_banner', 99 ); function utfa_import_nonce_ajax() { if ( current_user_can( 'manage_options' ) ) { wp_send_json_success( wp_create_nonce( 'utfa_import' ) ); } wp_die(); } add_action( 'wp_ajax_utfa_import_nonce_ajax', 'utfa_import_nonce_ajax' ); function utfa_import_stores_ajax() { if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( 'auth' ); return; } $raw = isset( $_POST['stores'] ) ? $_POST['stores'] : '[]'; $stores = json_decode( stripslashes( $raw ), true ); if ( ! is_array( $stores ) ) { wp_send_json_error( 'bad json' ); return; } $created = 0; $skipped = 0; foreach ( $stores as $s ) { $title = isset( $s['name'] ) ? sanitize_text_field( $s['name'] ) : ''; if ( empty( $title ) ) { $skipped++; continue; } $existing = get_posts( array( 'post_type' => 'wpsl_stores', 'title' => $title, 'posts_per_page' => 1, 'fields' => 'ids', ) ); if ( ! empty( $existing ) ) { $skipped++; continue; } $pid = wp_insert_post( array( 'post_title' => $title, 'post_type' => 'wpsl_stores', 'post_status' => 'publish', ) ); if ( is_wp_error( $pid ) ) { $skipped++; continue; } $map = array( 'wpsl_address' => 'address', 'wpsl_city' => 'city', 'wpsl_state' => 'state', 'wpsl_zip' => 'zip', 'wpsl_country' => 'country', 'wpsl_country_iso' => 'country_iso', 'wpsl_lat' => 'lat', 'wpsl_lng' => 'lng', 'wpsl_phone' => 'phone', ); foreach ( $map as $meta_key => $json_key ) { if ( isset( $s[ $json_key ] ) && $s[ $json_key ] !== '' ) { update_post_meta( $pid, $meta_key, sanitize_text_field( $s[ $json_key ] ) ); } } $created++; } wp_send_json_success( array( 'created' => $created, 'skipped' => $skipped ) ); } add_action( 'wp_ajax_utfa_import_stores_ajax', 'utfa_import_stores_ajax' ); function utfa_geocode_stores_ajax() { if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( 'auth' ); return; } $opt = get_option( 'wpsl_settings' ); $api_key = ( is_array( $opt ) && isset( $opt['api_server_key'] ) ) ? $opt['api_server_key'] : ''; if ( empty( $api_key ) && is_array( $opt ) && isset( $opt['api_browser_key'] ) ) { $api_key = $opt['api_browser_key']; } $limit = 10; $geocoded = 0; $failed = 0; $args = array( 'post_type' => 'wpsl_stores', 'posts_per_page' => $limit, 'fields' => 'ids', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'wpsl_lat', 'value' => '', 'compare' => '=' ), array( 'key' => 'wpsl_lat', 'compare' => 'NOT EXISTS' ), ), ); $ids = get_posts( $args ); foreach ( $ids as $pid ) { $address = get_post_meta( $pid, 'wpsl_address', true ); $city = get_post_meta( $pid, 'wpsl_city', true ); $state = get_post_meta( $pid, 'wpsl_state', true ); $zip = get_post_meta( $pid, 'wpsl_zip', true ); $query = urlencode( implode( ', ', array_filter( array( $address, $city, $state, $zip, 'Australia' ) ) ) ); $url = "https://maps.googleapis.com/maps/api/geocode/json?address={$query}&key={$api_key}"; $resp = wp_remote_get( $url, array( 'timeout' => 10 ) ); if ( is_wp_error( $resp ) ) { update_post_meta( $pid, 'wpsl_lat', '0' ); update_post_meta( $pid, 'wpsl_lng', '0' ); $failed++; continue; } $data = json_decode( wp_remote_retrieve_body( $resp ), true ); if ( isset( $data['results'][0]['geometry']['location'] ) ) { $loc = $data['results'][0]['geometry']['location']; update_post_meta( $pid, 'wpsl_lat', $loc['lat'] ); update_post_meta( $pid, 'wpsl_lng', $loc['lng'] ); $geocoded++; } else { update_post_meta( $pid, 'wpsl_lat', '0' ); update_post_meta( $pid, 'wpsl_lng', '0' ); $failed++; } } $remaining = count( get_posts( array( 'post_type' => 'wpsl_stores', 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'wpsl_lat', 'value' => '', 'compare' => '=' ), array( 'key' => 'wpsl_lat', 'compare' => 'NOT EXISTS' ) ) ) ) ); wp_send_json_success( array( 'geocoded' => $geocoded, 'failed' => $failed, 'remaining' => $remaining ) ); } add_action( 'wp_ajax_utfa_geocode_stores_ajax', 'utfa_geocode_stores_ajax' ); function utfa_wpsl_map_customizations() { ?> <script> // Override WPSL settings before the map initialises if (typeof wpslSettings !== 'undefined') { wpslSettings.maxResults = 100; wpslSettings.autoLoad = '1'; } document.addEventListener('DOMContentLoaded', function() { var attempts = 0; var interval = setInterval(function() { attempts++; if (attempts > 120) { clearInterval(interval); return; } if (typeof wpsl === 'undefined' || !wpsl.map) return; clearInterval(interval); function styleGoomallingMarker() { if (!wpsl.maps || !wpsl.maps.markers) return; wpsl.maps.markers.forEach(function(marker) { var pos = marker.getPosition(); if (!pos) return; if (Math.abs(pos.lat() - (-31.293)) < 0.05 && Math.abs(pos.lng() - 116.816) < 0.1) { marker.setIcon({ path: google.maps.SymbolPath.CIRCLE, scale: 20, fillColor: '#00c853', fillOpacity: 1, strokeColor: '#ffffff', strokeWeight: 3 }); marker.setZIndex(9999); } }); } google.maps.event.addListener(wpsl.map, 'idle', styleGoomallingMarker); styleGoomallingMarker(); }, 500); }); </script> <?php } add_action( 'wp_footer', 'utfa_wpsl_map_customizations', 99 ); function utfa_update_wpsl_max_results() { if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error(); return; } $settings = get_option( 'wpsl_settings', array() ); $settings['max_results'] = 100; $settings['results_dropdown'] = '5,10,25,50,100'; update_option( 'wpsl_settings', $settings ); wp_send_json_success( array( 'max_results' => $settings['max_results'] ) ); } add_action( 'wp_ajax_utfa_update_wpsl_max_results', 'utfa_update_wpsl_max_results' ); function utfa_read_wpsl_settings() { if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error(); return; } wp_send_json_success( get_option( 'wpsl_settings' ) ); } add_action( 'wp_ajax_utfa_read_wpsl_settings', 'utfa_read_wpsl_settings' ); function utfa_fix_wpsl_settings() { if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error(); return; } $s = get_option( 'wpsl_settings', array() ); $s['max_results'] = '25,50,[100]'; $s['results_dropdown'] = 0; $s['autoload'] = 1; $s['autoload_limit'] = 100; update_option( 'wpsl_settings', $s ); wp_send_json_success( array( 'max_results' => $s['max_results'], 'autoload' => $s['autoload'] ) ); } add_action( 'wp_ajax_utfa_fix_wpsl_settings', 'utfa_fix_wpsl_settings' ); function utfa_wpsl_settings_override() { $intercept = "(function(){var _s;Object.defineProperty(window,'wpslSettings',{configurable:true,get:function(){return _s;},set:function(v){if(v&&typeof v==='object'){v.autoLoad='1';v.maxResults=100;}Object.defineProperty(window,'wpslSettings',{configurable:true,writable:true,value:v});_s=v;}});})();"; wp_add_inline_script( 'jquery-core', $intercept, 'after' ); } add_action( 'wp_enqueue_scripts', 'utfa_wpsl_settings_override', 100 ); function utfa_find_wpsl_shortcode() { if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error(); return; } global $wpdb; $results = $wpdb->get_results( "SELECT meta_key, meta_value FROM {$wpdb->postmeta} WHERE post_id = 1501 AND meta_value LIKE '%wpsl%' LIMIT 5" ); $found = array(); foreach ( $results as $row ) { $found[] = array( 'key' => $row->meta_key, 'excerpt' => substr( strstr( $row->meta_value, 'wpsl' ), -20, 120 ) ); } // Also check post content $post = get_post( 1501 ); $content_excerpt = ''; if ( $post && strpos( $post->post_content, 'wpsl' ) !== false ) { $idx = strpos( $post->post_content, 'wpsl' ); $content_excerpt = substr( $post->post_content, max(0,$idx-10), 150 ); } wp_send_json_success( array( 'meta' => $found, 'content' => $content_excerpt ) ); } add_action( 'wp_ajax_utfa_find_wpsl_shortcode', 'utfa_find_wpsl_shortcode' ); // Force WPSL autoLoad via option filter add_filter('option_wpsl_settings', function($value) { if (is_array($value)) { $value['autoload'] = 1; } return $value; }); https://universaltrailers.com.au/page-sitemap.xml 2026-06-03T00:02:21+00:00 https://universaltrailers.com.au/tbuilder_layout_part-sitemap.xml 2026-05-28T15:20:31+00:00 https://universaltrailers.com.au/product-sitemap.xml 2026-06-02T23:27:58+00:00 https://universaltrailers.com.au/product_cat-sitemap.xml 2026-06-02T23:27:58+00:00