admin_url( 'admin-ajax.php' ), 'tm_nonce' => $tm_nonce, 'tm_delete_nonce' => $tm_delete_nonce, 'close_after_click' => $close_after_click, 'motors_grid_tabs' => $grid_tabs_widget, 'motors_ml_grid_tabs' => $ml_grid_tabs_widget, 'motors_car_listing_tabs' => $car_listing_tabs, ) ); } public static function motors_remove_post_type_supports() { } public static function motors_remove_inventory_settings_conf( $settings ) { unset( $settings['listing_sidebar'] ); unset( $settings['listing_filter_position'] ); return $settings; } public static function motors_remove_search_settings_conf( $settings ) { unset( $settings['listing_filter_position'] ); unset( $settings['listing_list_sort_slug'] ); return $settings; } public static function motors_remove_listing_settings_conf( $settings ) { unset( $settings['listing_directory_title_default'] ); return $settings; } public static function array_value_recursive( $post_id, $key, array $arr ) { array_walk_recursive( $arr, function ( $v, $k ) use ( $post_id, $key, &$val ) { $keys_for_save = array( 'ppp_on_list', 'ppp_on_grid', 'quant_grid_items', ); if ( in_array( $k, $keys_for_save, true ) ) { update_post_meta( $post_id, $k, $v ); } } ); } public static function motors_elementor_after_save( $post_id, $editor_data ) { self::array_value_recursive( $post_id, 'ppp_on_grid', $editor_data ); } public static function motors_modify_post_type_objects( $post_types_objects ) { unset( $post_types_objects['listings'] ); return $post_types_objects; } public static function stm_ew_kses_svg() { $kses_defaults = wp_kses_allowed_html( 'post' ); $svg = array( 'svg' => array( 'class' => true, 'aria-hidden' => true, 'aria-labelledby' => true, 'role' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true, ), 'g' => array( 'fill' => true ), 'title' => array( 'title' => true ), 'path' => array( 'd' => true, 'fill' => true, ), ); return array_merge( $kses_defaults, $svg ); } public static function close_after_click() { check_ajax_referer( 'motors_close_after_click', 'nonce' ); update_option( 'features_settings_clicked', 1 ); wp_send_json_success(); } public static function motors_ew_grid_tabs() { check_ajax_referer( 'motors_grid_tabs', 'security' ); $listing_types = apply_filters( 'stm_listings_post_type', 'listings' ); $tab_type = sanitize_text_field( $_POST['tab_type'] ); $per_page = intval( $_POST['per_page'] ); $template = sanitize_text_field( $_POST['template'] ); $img_size = sanitize_text_field( $_POST['img_size'] ); $args = array( 'post_type' => $listing_types, 'post_status' => 'publish', 'posts_per_page' => $per_page, ); if ( 'popular' === $tab_type ) { $args = array_merge( $args, array( 'orderby' => 'meta_value_num', 'meta_key' => 'stm_car_views', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key 'order' => 'DESC', ) ); } $args['meta_query'][] = array( 'key' => 'car_mark_as_sold', 'value' => '', 'compare' => '=', ); $template_args = array(); if ( ! empty( $img_size ) ) { $template_args = array( 'custom_img_size' => $img_size, ); } $listings_query = new WP_Query( $args ); if ( $listings_query->have_posts() ) { $output = ''; ob_start(); while ( $listings_query->have_posts() ) { $listings_query->the_post(); get_template_part( $template, null, $template_args ); } $output .= ob_get_clean(); } wp_send_json( array( 'html' => $output, ) ); } public static function motors_ew_ml_grid_tabs() { check_ajax_referer( 'motors_ml_grid_tabs', 'security' ); $listing_type = ( isset( $_POST['listing_type'] ) ) ? sanitize_text_field( $_POST['listing_type'] ) : 'listings'; $listing_type = ( isset( $_POST['listing_types'] ) ) ? explode( ',', sanitize_text_field( $_POST['listing_types'] ) ) : $listing_type; $tab_type = ( isset( $_POST['tab_type'] ) ) ? sanitize_text_field( $_POST['tab_type'] ) : ''; $per_page = ( isset( $_POST['per_page'] ) ) ? intval( $_POST['per_page'] ) : 4; $template = ( isset( $_POST['template'] ) ) ? sanitize_text_field( $_POST['template'] ) : ''; $order_by = ( isset( $_POST['order_by'] ) ) ? sanitize_text_field( $_POST['order_by'] ) : ''; $show_all_link = ( isset( $_POST['show_all_link'] ) ) ? sanitize_text_field( $_POST['show_all_link'] ) : ''; $show_all_text = ( isset( $_POST['show_all_text'] ) ) ? sanitize_text_field( $_POST['show_all_text'] ) : ''; $img_size = ( isset( $_POST['img_size'] ) ) ? sanitize_text_field( $_POST['img_size'] ) : null; $title_max_length = ( isset( $_POST['title_max_length'] ) ) ? sanitize_text_field( $_POST['title_max_length'] ) : ''; $args = array( 'post_type' => $listing_type, 'post_status' => 'publish', 'posts_per_page' => $per_page, ); if ( 'popular' === $order_by || 'popular' === $tab_type ) { $args = array_merge( $args, array( 'orderby' => 'meta_value_num', 'meta_key' => 'stm_car_views', 'order' => 'DESC', ) ); } elseif ( 'featured' === $tab_type ) { $args['order'] = 'rand'; $args['meta_query'][] = array( 'key' => 'special_car', 'value' => 'on', 'compare' => '=', ); } if ( ! empty( $tab_type ) ) { $args['meta_query'][] = array( 'key' => 'car_mark_as_sold', 'value' => '', 'compare' => '=', ); } $template_args = array( 'custom_img_size' => ( ! empty( $img_size ) ) ? $img_size : null, 'title_max_length' => ( ! empty( $title_max_length ) ) ? $title_max_length : null, ); $listing_cars = new WP_Query( $args ); ob_start(); ?> have_posts() ) : ?>
have_posts() ) : $listing_cars->the_post(); ?>
$output, ) ); } public static function motors_ew_car_listing_tabs() { check_ajax_referer( 'motors_car_listing_tabs', 'security' ); $per_page = intval( $_POST['per_page'] ); $taxonomy = sanitize_text_field( $_POST['taxonomy'] ); $terms = sanitize_text_field( $_POST['terms'] ); $found_cars_prefix = sanitize_text_field( $_POST['fc_prefix'] ); $found_cars_suffix = sanitize_text_field( $_POST['fc_suffix'] ); $enable_ajax_loading = sanitize_text_field( $_POST['enable_ajax_loading'] ); $img_size = sanitize_text_field( $_POST['img_size'] ); $found_cars_icon = $_POST['found_cars_icon']; $random_int = intval( $_POST['random_int'] ); $args = array( 'post_type' => apply_filters( 'stm_listings_post_type', 'listings' ), 'post_status' => 'publish', 'posts_per_page' => $per_page, ); $args['tax_query'][] = array( 'taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => array( $terms ), ); $args['meta_query'][] = array( 'key' => 'car_mark_as_sold', 'value' => '', 'compare' => '=', ); $template_args = array(); if ( ! empty( $img_size ) ) { $template_args = array( 'custom_img_size' => $img_size, ); } $listing_cars = new WP_Query( $args ); $friendly_url = apply_filters( 'motors_vl_get_nuxy_mod', false, 'friendly_url' ); $atts = ( $friendly_url ) ? esc_attr( $terms ) : '?' . esc_attr( $taxonomy ) . '=' . esc_attr( $terms ); $url = apply_filters( 'stm_filter_listing_link', '' ) . $atts; ob_start(); ?>
found_posts ); ?>
have_posts() ) : ?>
have_posts() ) : $listing_cars->the_post(); ?>
found_posts > $per_page ) : ?>
$output, ) ); } }