editor) && method_exists($plugin->editor, 'is_edit_mode')) { if ($plugin->editor->is_edit_mode()) { return true; } } } catch (\Throwable $e) { // Silently ignore and fall through to other checks } } // URL flags used by Elementor preview/editor if (!empty($_GET['elementor-preview'] ?? '') || !empty($_GET['elementor_library'] ?? '')) { return true; } // Admin AJAX render inside editor if (is_admin() && wp_doing_ajax()) { return true; } return false; } /** * Method __construct * * @return void */ public function __construct() { add_shortcode('adqs_listings', array($this, 'render_listing_shortcode')); add_shortcode('adqs_taxonomies', array($this, 'render_all_listing_categories')); add_shortcode('adqs_search', array($this, 'render_search_bar')); add_shortcode('adqs_social_share', array($this, 'render_social_share')); add_shortcode('adqs_dashboard', array($this, 'frontend_dashbaord')); add_shortcode('adqs_agents', array($this, 'render_all_agents')); //User login and registration add_shortcode('adqs_user_log_regi', array($this, 'user_log_regi')); } /** * Method render_all_agents * * @param $atts * * @return string */ public function render_all_agents($atts) { extract(shortcode_atts([ 'per_page' => 8, 'ajax_filter' => empty(adqs_get_setting_option('ajax_filters')) ? 'false' : 'true', 'nav_bar_show' => 'true', 'search_bar_show' => 'true', 'sort_by_show' => 'true', 'reset_filter' => 'true', 'directory_dropdown' => 4, 'from_addon' => 'false', 'style_type' => '', ], $atts)); $per_page = absint($per_page); $ajax_filter = $ajax_filter == 'true' ? true : false; $nav_bar_show = ('true' === $nav_bar_show) ? true : false; $search_bar_show = ('true' === $search_bar_show) ? true : false; $sort_by_show = ('true' === $sort_by_show) ? true : false; $reset_filter = ('true' === $reset_filter) ? true : false; $from_addon = ('true' === $from_addon) ? true : false; if (empty($from_addon)) { wp_enqueue_style('adqs_all_agents'); } static $ad_id = 1; if ($ajax_filter && ($ad_id === 1)) { wp_enqueue_script('adqs_all_agents'); wp_localize_script( 'adqs_all_agents', 'qsAgentsFilter', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('adqs_agent_ajax_filter'), ) ); } // Resolve current request context for data attributes ob_start(); if ($ajax_filter): ?>
is_elementor_preview()) { ob_start(); $loginPage = adqs_get_permalink_by_key('adqs_user_dashboard'); if (!empty($loginPage)) : ?>

"; } /** * Method render_all_listing_categories * * @param $atts * * @return string */ public function render_all_listing_categories($atts) { extract(shortcode_atts([ 'custom_directory' => '', 'tax_type' => 'categories', 'per_page' => 10, 'ajax_filter' => empty(adqs_get_setting_option('ajax_filters')) ? 'false' : 'true', 'top_bar_show' => 'true', 'search_bar_show' => 'true', 'pagination_type' => 'pagination', 'terms' => '', 'order' => 'DESC', 'orderby' => 'count', 'carousel_settings' => '', 'uniq_id' => '', 'from_addon' => 'false', 'column_basis' => '', 'column_gap' => '', 'directory_dropdown' => 5, 'style_type' => '', ], $atts)); global $wp; $directory_types = adqs_get_directories(); $active_type = sanitize_text_field($_REQUEST['directory_type'] ?? ''); // Taxonomies are now static and shared across all post types $category_taxonomy = 'adqs_category'; $location_taxonomy = 'adqs_location'; $tax_name = $tax_type === 'categories' ? $category_taxonomy : $location_taxonomy; if (empty($tax_name)) { return ''; } $ajax_filter = ('true' === $ajax_filter) ? true : false; if ($ajax_filter) { wp_enqueue_script('adqs_ajax_search'); wp_localize_script( 'adqs_ajax_search', 'qsAjxFilter', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('adqs_ajax_filter'), ) ); } $top_bar_show = ('true' === $top_bar_show) ? true : false; $search_bar_show = ('true' === $search_bar_show) ? true : false; $from_addon = ('true' === $from_addon) ? true : false; wp_enqueue_style('adqs_taxonomy_archive'); $uniqId = !empty($uniq_id) ? $uniq_id : uniqid(); $isSlick = false; if ($pagination_type === 'carousel') { $carousel_settings = apply_filters("adqs_taxonomy_carousel_settings", $carousel_settings, $tax_name); if (empty($from_addon)) { wp_enqueue_style('slick'); wp_enqueue_style('slick-init'); wp_enqueue_script('slick'); wp_enqueue_script('slick-init'); } $isSlick = true; } $custom_directory = !empty($custom_directory) ? explode(',', $custom_directory) : []; // If Include Directories is provided AND no URL parameter specified, use first from custom list // URL parameter always takes precedence // Note: We don't need to fetch taxonomies dynamically since they're now static if (!empty($custom_directory) && empty($active_type)) { $active_type = (! empty($custom_directory) && count($custom_directory) === 1) ? ($custom_directory[0] ?? '') : ''; } $per_page = (int) $per_page; $args = [ 'taxonomy' => $tax_name, 'hide_empty' => true, 'number' => $per_page, 'order' => $order, 'orderby' => $orderby, ]; // Use the already fetched directory types instead of calling the function again $all_listing_type = $directory_types; $allTermsIds = []; // Determine which directories to filter by $directories_to_filter = []; // If a specific directory type is selected via URL parameter, use only that directory if (!empty($active_type) && empty($terms)) { $directories_to_filter = [$active_type]; } // If "All" is selected (empty active_type) and custom_directory is specified, use custom directories elseif (empty($active_type) && !empty($custom_directory) && empty($terms)) { $directories_to_filter = $custom_directory; } // Filter terms by the determined directories if (!empty($directories_to_filter) && empty($terms)) { // Convert directory slugs to post types using proper function $directory_post_types = []; foreach ($directories_to_filter as $dir_slug) { $post_type = adqs_get_post_type_by_directory($dir_slug); if (!empty($post_type) && post_type_exists($post_type)) { $directory_post_types[] = $post_type; } } if (!empty($directory_post_types)) { // Query posts from these specific post types $posts_query = new \WP_Query([ 'post_type' => $directory_post_types, 'posts_per_page' => -1, 'fields' => 'ids', 'tax_query' => [ [ 'taxonomy' => $tax_name, 'operator' => 'EXISTS', ], ], ]); if ($posts_query->have_posts()) { // Get all term IDs associated with these posts $term_ids = []; foreach ($posts_query->posts as $post_id) { $post_terms = wp_get_post_terms($post_id, $tax_name, ['fields' => 'ids']); if (!is_wp_error($post_terms) && !empty($post_terms)) { $term_ids = array_merge($term_ids, $post_terms); } } $allTermsIds = array_unique($term_ids); if (!empty($allTermsIds)) { $args['include'] = $allTermsIds; } } wp_reset_postdata(); } } // If specific terms are provided via the terms parameter, use them (overrides directory filtering) $terms_all = ''; if (!empty($terms)) { $terms_all = $terms; $terms = json_decode($terms, true); $terms = $terms[$tax_name] ?? ''; $terms = adqs_covertTerm_slug_to_id($terms, $tax_name); $allTermsIds = array_map('absint', explode(',', $terms)); $args['include'] = $allTermsIds; } if (!empty($_REQUEST['tax_search'] ?? '')) { $args['search'] = $_REQUEST['tax_search']; } $allTermsIds = array_unique(array_filter($allTermsIds)); $pagination_args = []; if (($pagination_type === 'pagination') && $per_page > 0) { $page = (get_query_var('paged')) ? get_query_var('paged') : 1; $args['offset'] = ($page - 1) * $per_page; // Pagination - count total terms $totalArgs = [ 'taxonomy' => $tax_name, 'hide_empty' => true, ]; // If we have filtered terms (from directory or manual selection), count only those if (!empty($allTermsIds)) { $totalArgs['include'] = $allTermsIds; } if (!empty($_REQUEST['tax_search'] ?? '')) { $totalArgs['search'] = $_REQUEST['tax_search']; } $total_terms = wp_count_terms($totalArgs); $pagination_args = array( 'base' => str_replace(999999999, '%#%', get_pagenum_link(999999999, false)), 'format' => '?paged=%#%', 'current' => $page, 'total' => ceil($total_terms / $per_page), 'show_all' => false, 'type' => 'list', 'prev_next' => true, 'prev_text' => '', 'next_text' => '', ); } $get_category_terms = get_terms($args); // Determine template slug based on taxonomy type $template_slug = 'taxonomy'; if ($tax_type === 'locations') { $template_slug = 'taxonomy-locations'; } ob_start(); if (empty($from_addon)): ?>
data-carousel-settings="" >
'true', 'ajax_filter' => empty(adqs_get_setting_option('ajax_filters')) ? 'false' : 'true', 'filter_layout' => adqs_get_setting_option('filterLayoutPosition') === 'sidebar' ? 'sidebar' : 'top', 'top_bar_show' => 'true', 'pagination_type' => 'pagination', 'reset_filter' => 'true', 'sort_by_show' => 'true', 'view_bar_show' => 'true', 'has_map_view' => 'true', 'per_page' => '', 'custom_directory' => '', 'categories' => '', 'locations' => '', 'tags' => '', 'rating' => '', 'display_listings' => '', 'sort_by' => '', 'from_addon' => 'false', 'view_type' => 'grid', 'carousel_settings' => '', 'grid_columns' => 3, 'grid_columns_gap' => '', 'list_columns' => 2, 'list_columns_gap' => '', 'uniq_id' => '', 'post__not_in' => '', 'directory_dropdown' => 5, 'style_type' => '', 'next_icon' => '', 'prev_icon' => '', ], $atts)); global $wp; $from_addon = ('true' === $from_addon) ? true : false; // get all list page id if (empty($from_addon)) { $alllistingspage_option_key = 'adqs_all_listings_page'; $get_alllistingspage_id = absint(get_option($alllistingspage_option_key, 0)); if ($get_alllistingspage_id !== get_the_ID()) { update_option($alllistingspage_option_key, get_the_ID()); } } $uniqId = !empty($uniq_id) ? $uniq_id : uniqid(); if ($pagination_type === 'carousel') { $carousel_settings = apply_filters("adqs_listing_carousel_settings", $carousel_settings); if (empty($from_addon)) { wp_enqueue_style('slick'); wp_enqueue_style('slick-init'); wp_enqueue_script('slick'); wp_enqueue_script('slick-init'); } } $filter_show = ('true' === $filter_show) ? true : false; $top_bar_show = ('true' === $top_bar_show) ? true : false; $reset_filter = ('true' === $reset_filter) ? true : false; $sort_by_show = ('true' === $sort_by_show) ? true : false; $has_map_view = ('true' === $has_map_view) ? true : false; $view_bar_show = ('true' === $view_bar_show) ? true : false; $ajax_filter = ('true' === $ajax_filter) ? true : false; $filter_layout = !$filter_show ? 'top' : $filter_layout; $paged = !empty(adqs_post_paged()) ? adqs_post_paged() : 1; $setting_per_page = !empty(AD()->Helper->get_setting('listing_per_page')) ? intval(AD()->Helper->get_setting('listing_per_page')) : 6; $per_page = $per_page ? (int) $per_page : $setting_per_page; $queryArgs = array( 'post_status' => 'publish', 'posts_per_page' => $per_page, 'paged' => $paged, ); $queryArgs['custom_directory'] = $custom_directory; if (!empty($categories)) { $queryArgs['categories'] = $categories; } if (!empty($locations)) { $queryArgs['locations'] = $locations; } if (!empty($tags)) { $queryArgs['tags'] = adqs_covertTerm_slug_to_id($tags); } if (!empty($rating)) { $queryArgs['rating'] = $rating; } if (!empty($display_listings)) { $queryArgs['display_listings'] = $display_listings; } // Add custom fields from query string $notFiltersKeys = ['view_type', 'sort_by']; foreach ($_REQUEST as $key => $value) { if (!in_array($key, $notFiltersKeys) && !isset($queryArgs[$key])) { if (is_array($value)) { $queryArgs[$key] = array_map('sanitize_text_field', $value); } else { $cleanValue = sanitize_text_field($value); if (!empty($cleanValue)) { $queryArgs[$key] = $cleanValue; } } } } $setQueryArgs = adqs_listing_query_filter_args($queryArgs); /** * Short By */ $sortByArgs = adqs_listing_query_sort_by($sort_by); if (!empty($sortByArgs)) { $setQueryArgs = array_merge($setQueryArgs, $sortByArgs); } if (!empty($post__not_in)) { $post__not_in = array_map(function ($id) { return absint($id); }, explode(',', $post__not_in)); $setQueryArgs['post__not_in'] = $post__not_in; } if (isset($_GET['view_type'])) { $view_type = $_GET['view_type']; } $setQueryArgs['post_status'] = 'publish'; $listings_query = new \WP_Query($setQueryArgs); $custom_directory = !empty($custom_directory) ? explode(',', $custom_directory) : []; $isSlick = ($pagination_type === 'carousel') ? true : false; $one_dir = ''; if ($ajax_filter && !empty($custom_directory ?? []) && count($custom_directory) === 1) { $one_dir = $custom_directory[0] ?? ''; } static $ad_id = 1; if ($ajax_filter && ($ad_id === 1)) { wp_enqueue_script('adqs_ajax_search'); wp_localize_script( 'adqs_ajax_search', 'qsAjxFilter', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('adqs_ajax_filter'), ) ); } ob_start(); do_action('adqs_before_main_content'); if (empty($from_addon)): ?>
data-carousel-settings="" >
'false', 'custom_directory' => '', 'directory_dropdown' => 6, 'display_categories' => 'true', 'display_locations' => 'true', 'search_page_url' => '', 'new_tab' => 'true', 'style_type' => '', ], $atts)); $from_addon = ('true' === $from_addon) ? true : false; $new_tab = ('true' === $new_tab) ? true : false; $display_categories = ('true' === $display_categories) ? true : false; $display_locations = ('true' === $display_locations) ? true : false; $custom_directory = !empty($custom_directory) ? explode(',', $custom_directory) : []; ob_start(); do_action('adqs_before_main_content'); adqs_get_template_part('global/search', 'bar', compact('search_page_url', 'new_tab', 'custom_directory', 'directory_dropdown', 'display_categories', 'display_locations', 'style_type')); do_action('adqs_after_main_content'); return ob_get_clean(); } /** * Generate pagination with dots for large page counts * * @param int $current_page Current page number * @param int $total_pages Total number of pages * @param string $page_url Base URL for pagination * @param bool $ajax_filter Whether AJAX filtering is enabled * @return array Array of pagination items */ public function generate_pagination_with_dots($current_page, $total_pages, $page_url = '', $ajax_filter = false) { $pagination_items = []; // Always show first page $pagination_items[] = [ 'type' => 'page', 'number' => 1, 'current' => ($current_page == 1), 'url' => $this->get_pagination_url(1, $page_url, $ajax_filter) ]; // Calculate range around current page $range = 2; // Show 2 pages before and after current page $start = max(2, $current_page - $range); $end = min($total_pages - 1, $current_page + $range); // Add dots after first page if needed if ($start > 2) { $pagination_items[] = [ 'type' => 'dots', 'text' => '...' ]; } // Add pages in range for ($i = $start; $i <= $end; $i++) { $pagination_items[] = [ 'type' => 'page', 'number' => $i, 'current' => ($i == $current_page), 'url' => $this->get_pagination_url($i, $page_url, $ajax_filter) ]; } // Add dots before last page if needed if ($end < $total_pages - 1) { $pagination_items[] = [ 'type' => 'dots', 'text' => '...' ]; } // Always show last page (if more than 1 page) if ($total_pages > 1) { $pagination_items[] = [ 'type' => 'page', 'number' => $total_pages, 'current' => ($current_page == $total_pages), 'url' => $this->get_pagination_url($total_pages, $page_url, $ajax_filter) ]; } return $pagination_items; } /** * Get pagination URL for a specific page * * @param int $page_number Page number * @param string $page_url Base URL * @param bool $ajax_filter Whether AJAX filtering is enabled * @return string URL for the page */ public function get_pagination_url($page_number, $page_url = '', $ajax_filter = false) { if ($ajax_filter && !empty($page_url)) { return add_query_arg(['adqs_page' => $page_number], $page_url); } return esc_url(adqs_get_current_page_url(['adqs_page' => $page_number])); } /** * Method render_social_share * * @param $atts * @param $content * * @return string */ public function render_social_share($atts, $content = null) { // Get current page URL $sb_url = urlencode(get_permalink()); // Get current page title $sb_title = get_the_title(); // Get Post Thumbnail for Pinterest $sb_thumb = get_the_post_thumbnail_url(); // Construct sharing URLs without using any script $facebookURL = 'https://www.facebook.com/sharer/sharer.php?u=' . $sb_url; $twitterURL = 'https://twitter.com/intent/tweet?text=' . $sb_title . '&url=' . $sb_url . '&via=adqs_listing'; $pinterestURL = add_query_arg(['description' => $sb_title, 'url' => $sb_url, 'media' => $sb_thumb], 'https://pinterest.com/pin/create/button'); $linkedinURL = 'https://www.linkedin.com/sharing/share-offsite/?url=' . $sb_url; $whatsappURL = 'https://api.whatsapp.com/send?text=' . $sb_title . ' ' . $sb_url; $redditURL = 'https://www.reddit.com/submit?url=' . $sb_url . '&title=' . $sb_title; $telegramURL = 'https://t.me/share/url?url=' . $sb_url . '&text=' . $sb_title; ob_start(); ?> img