/*
Theme Name: Houzez
Theme URI: http://houzez.co/
Author: Favethemes 
Author URI: http://www.favethemes.com/
Description: Houzez is a premium WordPress theme for real estate agents where modern aesthetics are combined with tasteful simplicity, and where the ease of use is achieved without compromise in your ability to customise the design. Whether you are a real estate agent looking to build a website for your company or a web developer seeking a perfect WordPress theme for your next project, you are certain to appreciate the numerous features and benefits that our theme provides.
Version: 4.4.3
Tags: right-sidebar, left-sidebar, custom-colors, custom-menu, featured-images, post-formats, theme-options, translation-ready
License: GNU General Public License version 3.0 
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Text Domain: houzez
Requires at least: WordPress 6.0
*/
.auto-complete-content-wrap .item-sub-price,.houzez-dashboard .grecaptcha-badge,.listing-v3 .item-wrap-v3 .h-type,body.houzez-halfmap-page .grecaptcha-badge{display:none!important}.listing-slider-variable-width .slick-slide{padding-left:2px;padding-right:2px}.property-banner-trigger{z-index:1}.houzez-nav-menu-main-desktop-wrap .dropdown-menu>li:not(:last-child){border-top-width:0;border-left-width:0;border-right-width:0}.houzez-all-slider-wrap{opacity:0;visibility:hidden;transition:opacity 1s;-webkit-transition:opacity 1s}.houzez-all-slider-wrap.slick-initialized{visibility:visible;opacity:1}.property-carousel-module .slick-slide{padding-left:10px;padding-right:10px}.property-carousel-module .slick-list{margin-left:-10px;margin-right:-10px}.search-hidden,.sticky-nav-area,.sticky-search-area{position:relative;width:100%;z-index:1000;top:0;opacity:0;visibility:hidden;transform:translate(0,-200px)}.houzez-in-view{opacity:1;position:fixed!important;visibility:visible;transition:.4s;transform:translate(0,0) scale(1);animation:.4s fadein}.comment-reply-title{font-size:14px}@media (max-width:992px){.grecaptcha-badge{display:none!important}}.houzez-hide-menu-mobile,.houzez-hide-menu-tablet,.houzez-menu-toggle.houzez-nav-menu-active .icon-navigation-menu,.houzez-nav-menu-main-mobile-wrap.nav-mobile,[data-elementor-device-mode=mobile] .houzez-hide-menu-mobile,[data-elementor-device-mode=mobile] .houzez-hide-menu-tablet,[data-elementor-device-mode=tablet] .houzez-hide-menu-tablet{display:none}[data-elementor-device-mode=desktop] .houzez-show-menu-desktop,[data-elementor-device-mode=desktop] .hz-show-menu-desktop,[data-elementor-device-mode=mobile] .houzez-show-menu-desktop,[data-elementor-device-mode=mobile] .houzez-show-menu-mobile,[data-elementor-device-mode=mobile] .houzez-show-menu-tablet,[data-elementor-device-mode=tablet] .houzez-show-menu-desktop,[data-elementor-device-mode=tablet] .houzez-show-menu-tablet,[data-elementor-device-mode=tablet] .hz-show-menu-tablet{display:block}.slick-dots li{margin:0}.fancybox__container,.offcanvas.show,.offcanvas.showing{z-index:99999}.block-map-wrap{min-height:350px}.property-schedule-tour-day-form{max-height:100px}div#houzez-agent-sidebar-map{width:100%;height:200px}.houzez-map-message{position:absolute;bottom:20px;left:20px;background-color:rgba(0,0,0,.8);color:#fff;padding:6px 15px;border-radius:4px;font-size:13px;z-index:1000;opacity:0;transition:opacity .3s;pointer-events:none;line-height:20px}.map-marker-label,.property-info-window{background-color:#fff;box-shadow:rgba(0,0,0,.2) 0 3px 15px 0}.houzez-map-message.show{opacity:1}.property-info-window{padding:5px;border-radius:6px 0 6px 6px;width:287px}.property-info-window .info-window-image img{border-radius:4px;width:100%;max-width:286px;height:176px;object-fit:cover}.info-window-price{font-size:20px;font-weight:700;margin-bottom:10px}.info-window-info-details{font-size:14px;margin-bottom:5px;font-weight:400}.info-window-property-type{text-transform:uppercase;font-size:12px;font-weight:400;margin-bottom:10px}.info-window-address-info{font-size:14px;font-weight:400;color:#888}.info-window-image{position:relative}.info-window-label{position:absolute;font-weight:400;z-index:1;top:10px;left:10px;border-radius:4px;font-size:10px;line-height:1;text-transform:uppercase;padding:4px 4px 3px}.map-marker-label{color:#000;font-size:15px;font-weight:700;padding:8px 12px;border-radius:20px;border:1px solid #fff}.map-marker-label:hover{border:1px solid #aaa}.osm-marker{display:inline-block;padding:5px 11px}@media (max-width:991.98px){.single-property .back-to-top-wrap{right:10px;bottom:80px}}.is-invalid{border-color:#ea3d3d!important}button.gm-svpc>div{position:relative!important;top:0!important;left:0!important}@keyframes spin{from{transform:rotate(0)}to{transform:rotate(360deg)}}.icon-spin{display:inline-block;animation:2s linear infinite spin}.houzez-ele-search-form-wrapper .location-trigger{right:1px}.item-wrap-v4 .item-wrap>div,.property-detail-v3 #property-gallery-js .lslide a img,.property-detail-v4 #property-gallery-js .lslide a img{width:100%}.property-detail-v4 .top-gallery-section .lSPager.lSGallery{max-height:117px}.property-detail-v3 .top-gallery-section .lSPager.lSGallery{max-height:81px}#houzez-single-listing-map-address,#houzez-single-listing-map-elementor{height:100%;width:100%}.hs-gallery-v2-top-wrap #pills-360tour,.hs-gallery-v2-top-wrap #pills-map,.hs-gallery-v2-top-wrap #pills-street-view,.hs-gallery-v2-top-wrap #pills-video,.hs-gallery-v2-top-wrap .top-gallery-section,.hs-gallery-v3-top-wrap #pills-360tour,.hs-gallery-v3-top-wrap #pills-map,.hs-gallery-v3-top-wrap #pills-street-view,.hs-gallery-v3-top-wrap #pills-video{position:relative;aspect-ratio:4/3;overflow:hidden}textarea.form-control{line-height:inherit}.hz-place-autocomplete-wrap{flex:1;min-width:0;font-size:1rem}.hz-place-autocomplete-wrap.elementor-size-xs{font-size:13px}.hz-place-autocomplete-wrap.elementor-size-md{font-size:16px}.hz-place-autocomplete-wrap.elementor-size-lg{font-size:18px}.hz-place-autocomplete-wrap.elementor-size-xl{font-size:20px}gmp-place-autocomplete{display:block;width:100%;height:42px;background:#fff;outline:0}.hz-place-autocomplete-wrap.elementor-size-xs gmp-place-autocomplete{height:33px}.hz-place-autocomplete-wrap.elementor-size-md gmp-place-autocomplete{height:47px}.hz-place-autocomplete-wrap.elementor-size-lg gmp-place-autocomplete{height:59px}.hz-place-autocomplete-wrap.elementor-size-xl gmp-place-autocomplete{height:72px}.location-trigger{border-right:none!important;border-bottom:none!important;border-top:none!important}.property-tools-widget .item-tools-v4 .item-tool-preview{width:34px;height:34px;border:0;border-radius:50%}.property-detail-v1 .property-banner .nav,.property-detail-v2 .property-banner .nav{z-index:2}
add_filter('gettext', 'houzez_dashboard_turkcelestir', 20, 3);
function houzez_dashboard_turkcelestir($translated_text, $text, $domain) {
    if ($text == 'Dashboard') {
        return 'Kontrol Paneli';
    }
    if ($text == 'Favorite Properties') {
        return 'Favori İlanlarım';
    }
    if ($text == 'Activities') {
        return 'Etkinlikler';
    }
    if ($text == 'Insight') {
        return 'İstatistikler';
    }
    return $translated_text;
}
<?php
/**
 * Houzez functions and definitions.
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Houzez
 * @since Houzez 1.0
 * @author Waqas Riaz
 */

include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
global $wp_version;

/**
*	---------------------------------------------------------------------------------------
*	Define constants
*	---------------------------------------------------------------------------------------
*/
define( 'HOUZEZ_THEME_NAME', 'Houzez' );
define( 'HOUZEZ_THEME_SLUG', 'houzez' );
define( 'FLM_PRODUCT_SLUG', 'houzez');
define( 'HOUZEZ_THEME_VERSION', '4.4.3' );
define( 'HOUZEZ_FRAMEWORK', get_template_directory() . '/framework/' );
define( 'HOUZEZ_WIDGETS', get_template_directory() . '/inc/widgets/' );
define( 'HOUZEZ_INC', get_template_directory() . '/inc/' );
define( 'HOUZEZ_TEMPLATE_PARTS', get_template_directory() . '/template-parts/' );
define( 'HOUZEZ_IMAGE', get_template_directory_uri() . '/img/' );
define( 'HOUZEZ_CSS_DIR_URI', get_template_directory_uri() . '/css/' );
define( 'HOUZEZ_JS_DIR_URI', get_template_directory_uri() . '/js/' );

/**
*	----------------------------------------------------------------------------------------
*	Set up theme default and register various supported features.
*	----------------------------------------------------------------------------------------
*/
if ( ! function_exists( 'houzez_setup' ) ) {
	
	function houzez_setup() {

		/* add title tag support */
		add_theme_support( 'title-tag' );

		/* Load parent theme languages */
		load_theme_textdomain( 'houzez', get_template_directory() . '/languages' );

		/* Load child theme languages to override parent's translations */
		load_child_theme_textdomain( 'houzez', get_stylesheet_directory() . '/languages' );

		/* Add default posts and comments RSS feed links to head */
		add_theme_support( 'automatic-feed-links' );

		//Add support for post thumbnails.
		add_theme_support( 'post-thumbnails' );

		/**
		*	Register nav menus. 
		*/
		register_nav_menus(
			array(
				'top-menu' => esc_html__( 'Top Menu', 'houzez' ),
				'main-menu' => esc_html__( 'Main Menu', 'houzez' ),
				'main-menu-left' => esc_html__( 'Menu Left', 'houzez' ),
				'main-menu-right' => esc_html__( 'Menu Right', 'houzez' ),
				'mobile-menu-hed6' => esc_html__( 'Mobile Menu Header 6', 'houzez' ),
				'footer-menu' => esc_html__( 'Footer Menu', 'houzez' )
			)
		);

		/*
		 * Switch default core markup for search form, comment form, and comments
		 * to output valid HTML5.
		 */
		add_theme_support( 'html5', array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
		) );

		/*
		 * Enable support for Post Formats.
		 * See https://developer.wordpress.org/themes/functionality/post-formats/
		 */
		add_theme_support( 'post-formats', array(

		) );

		//remove gallery style css
		add_filter( 'use_default_gallery_style', '__return_false' );

		update_option( 'redux-framework_extendify_plugin_notice', 'hide' );
	
		/*
		 * Adds `async` and `defer` support for scripts registered or enqueued by the theme.
		 */
		$loader = new Houzez_Script_Loader();
		add_filter( 'script_loader_tag', array( $loader, 'filter_script_loader_tag' ), 10, 2 );
	}
}
add_action( 'after_setup_theme', 'houzez_setup' );


remove_filter( 'pre_user_description', 'wp_filter_kses' );
// Add sanitization for WordPress posts.
add_filter( 'pre_user_description', 'wp_filter_post_kses' );

/**
 *	---------------------------------------------------------------------------------------
 *	Options Admin Panel
 *	---------------------------------------------------------------------------------------
 */
require_once( HOUZEZ_FRAMEWORK . 'options/remove-tracking-class.php' ); // Remove tracking
require_once( HOUZEZ_FRAMEWORK . 'options/houzez-option.php' );

if( ! function_exists( 'houzez_load_redux_config' ) ) {
	function houzez_load_redux_config() {
		if ( class_exists( 'ReduxFramework' ) ) {
			require_once(get_theme_file_path('/framework/options/houzez-options.php'));
			require_once(get_theme_file_path('/framework/options/main.php'));
		}
	}
}
add_action('after_setup_theme', 'houzez_load_redux_config', 20);

/**
 *	---------------------------------------------------------------------
 *	Hooks
 *	---------------------------------------------------------------------
 */
require_once( HOUZEZ_FRAMEWORK . 'template-hooks.php' );


/**
 *	---------------------------------------------------------------------
 *	Functions
 *	---------------------------------------------------------------------
 */
require_once( HOUZEZ_FRAMEWORK . 'functions/template-functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/price_functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/helper_functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/taxonomy-helper.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/cache.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/map-functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/profile_functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/property_functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/property_schema.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/captcha-functions.php' ); // Unified captcha system
require_once( HOUZEZ_FRAMEWORK . 'functions/email-sender.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/emails-functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/blog-functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/membership-functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/cron-functions.php' );
require_once( HOUZEZ_FRAMEWORK . 'functions/property-expirator.php');
require_once( HOUZEZ_FRAMEWORK . 'functions/messages_functions.php');
require_once( HOUZEZ_FRAMEWORK . 'functions/property_rating.php');
require_once( HOUZEZ_FRAMEWORK . 'functions/menu-walker.php');
require_once( HOUZEZ_FRAMEWORK . 'functions/mobile-menu-walker.php');
require_once( HOUZEZ_FRAMEWORK . 'functions/review.php');
require_once( HOUZEZ_FRAMEWORK . 'functions/stats.php');
require_once( HOUZEZ_FRAMEWORK . 'functions/agency_agents.php');
require_once( HOUZEZ_FRAMEWORK . 'admin/menu/menu.php');

if ( class_exists( 'WooCommerce', false ) ) {
	require_once( HOUZEZ_FRAMEWORK . 'functions/woocommerce.php' );
}

require_once( get_template_directory() . '/template-parts/header/partials/favicon.php' );

require_once(get_theme_file_path('localization.php'));

require_once( HOUZEZ_FRAMEWORK . 'backward-compatibility.php' );

// Load Favethemes License Manager (theme-integrated)
require_once( HOUZEZ_FRAMEWORK . 'flm-loader.php' );

/**
 *	---------------------------------------------------------------------
 *	Classes
 *	---------------------------------------------------------------------
 */
require_once( HOUZEZ_FRAMEWORK . 'class-houzez-query.php' );
require_once( HOUZEZ_FRAMEWORK . 'class-houzez-data-source.php' );
require_once( HOUZEZ_FRAMEWORK . 'class-script-loader.php');
require_once( HOUZEZ_FRAMEWORK . 'class-houzez-lazy-load.php');
require_once( HOUZEZ_FRAMEWORK . 'admin/class-admin.php');
require_once( HOUZEZ_FRAMEWORK . 'admin/velisto.php');
require_once( HOUZEZ_FRAMEWORK . 'admin/wazlytics-promo.php');
require_once( HOUZEZ_FRAMEWORK . 'class-houzez-property-submit.php');
require_once( HOUZEZ_FRAMEWORK . 'class-houzez-property-search.php');
require_once( HOUZEZ_FRAMEWORK . 'class-houzez-user-verification.php');

/**
 *	---------------------------------------------------------------------------------------
 *	Yelp
 *	---------------------------------------------------------------------------------------
 */
require_once( get_template_directory() . '/inc/yelpauth/yelpoauth.php' );

/**
 *	---------------------------------------------------------------------------------------
 *	include metaboxes
 *	---------------------------------------------------------------------------------------
 */
if( is_admin() ) {
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/property-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/property-additional-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/agency-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/agent-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/partner-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/testimonials-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/posts-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/packages-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/reviews-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/project-metaboxes.php' );

	if( houzez_check_classic_editor () ) {
		require_once( get_theme_file_path('/framework/metaboxes/listings-templates-metaboxes-classic-editor.php') );
		require_once( get_theme_file_path('/framework/metaboxes/page-header-metaboxes-classic-editor.php') );
	} else {
		require_once( get_theme_file_path('/framework/metaboxes/listings-templates-metaboxes.php') );
		require_once( get_theme_file_path('/framework/metaboxes/page-header-metaboxes.php') );
	}


	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/header-search-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/page-template-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/transparent-menu-metaboxes.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/taxonomies-metaboxes.php' );

	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/status-meta.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/type-meta.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/label-meta.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/cities-meta.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/state-meta.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/area-meta.php' );
	require_once( HOUZEZ_FRAMEWORK . 'metaboxes/metaboxes.php' );
}


/**
 *	----------------------------------------------------------------
 *	Enqueue scripts and styles.
 *	----------------------------------------------------------------
 */
require_once( HOUZEZ_INC . 'register-scripts.php' );


/**
 *	----------------------------------------------------------------
 *	Better JPG and SSL 
 *	----------------------------------------------------------------
 */
require_once( HOUZEZ_FRAMEWORK . 'thumbnails/better-jpgs.php');
require_once( HOUZEZ_FRAMEWORK . 'thumbnails/honor-ssl-for-attachments.php');

/**
 *	-----------------------------------------------------------------------------------------
 *	Styling
 *	-----------------------------------------------------------------------------------------
 */
if ( class_exists( 'ReduxFramework' ) ) {
	require_once( get_template_directory() . '/inc/styling-options.php' );
}

if ( houzez_check_elementor_installed() ) {
	require get_template_directory() . '/inc/blocks/blocks.php';
}

/**
 *	---------------------------------------------------------------------------------------
 *	Widgets
 *	---------------------------------------------------------------------------------------
 */
require_once(get_theme_file_path('/framework/widgets/about.php'));
require_once(get_theme_file_path('/framework/widgets/code-banner.php'));
require_once(get_theme_file_path('/framework/widgets/mortgage-calculator.php'));
require_once(get_theme_file_path('/framework/widgets/image-banner-300-250.php'));
require_once(get_theme_file_path('/framework/widgets/contact.php'));
require_once(get_theme_file_path('/framework/widgets/properties.php'));
require_once(get_theme_file_path('/framework/widgets/featured-properties.php'));
require_once(get_theme_file_path('/framework/widgets/properties-viewed.php'));
require_once(get_theme_file_path('/framework/widgets/property-taxonomies.php'));
require_once(get_theme_file_path('/framework/widgets/latest-posts.php'));
require_once(get_theme_file_path('/framework/widgets/agents-search.php'));
require_once(get_theme_file_path('/framework/widgets/agency-search.php'));
require_once(get_theme_file_path('/framework/widgets/advanced-search.php'));

 /**
 *	---------------------------------------------------------------------------------------
 *	Set up the content width value based on the theme's design.
 *	---------------------------------------------------------------------------------------
 */
if( !function_exists('houzez_content_width') ) {
	function houzez_content_width()
	{
		$GLOBALS['content_width'] = apply_filters('houzez_content_width', 1170);
	}

	add_action('after_setup_theme', 'houzez_content_width', 0);
}

/**
 *	------------------------------------------------------------------
 *	Visual Composer
 *	------------------------------------------------------------------
 */
if (is_plugin_active('js_composer/js_composer.php') && is_plugin_active('houzez-theme-functionality/houzez-theme-functionality.php') ) {

	if( !function_exists('houzez_include_composer') ) {
		function houzez_include_composer()
		{
			require_once(get_template_directory() . '/framework/vc_extend.php');
		}

		add_action('init', 'houzez_include_composer', 9999);
	}

	// Filter to replace default css class names for vc_row shortcode and vc_column
	if( !function_exists('houzez_custom_css_classes_for_vc_row_and_vc_column') ) {
		//add_filter('vc_shortcodes_css_class', 'houzez_custom_css_classes_for_vc_row_and_vc_column', 10, 2);
		function houzez_custom_css_classes_for_vc_row_and_vc_column($class_string, $tag)
		{
			if ($tag == 'vc_row' || $tag == 'vc_row_inner') {
				$class_string = str_replace('vc_row-fluid', 'row-fluid', $class_string);
				$class_string = str_replace('vc_row', 'row', $class_string);
				$class_string = str_replace('wpb_row', '', $class_string);
			}
			if ($tag == 'vc_column' || $tag == 'vc_column_inner') {
				$class_string = preg_replace('/vc_col-sm-(\d{1,2})/', 'col-sm-$1', $class_string);
				$class_string = str_replace('wpb_column', '', $class_string);
				$class_string = str_replace('vc_column_container', '', $class_string);
			}
			return $class_string;
		}
	}

}

/*-----------------------------------------------------------------------------------*/
/*	Register blog sidebar, footer and custom sidebar
/*-----------------------------------------------------------------------------------*/
if( !function_exists('houzez_widgets_init') ) {
	add_action('widgets_init', 'houzez_widgets_init');
	function houzez_widgets_init()
	{
		register_sidebar(array(
			'name' => esc_html__('Default Sidebar', 'houzez'),
			'id' => 'default-sidebar',
			'description' => esc_html__('Widgets in this area will be shown in the blog sidebar.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Property Listings', 'houzez'),
			'id' => 'property-listing',
			'description' => esc_html__('Widgets in this area will be shown in property listings sidebar.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Search Sidebar', 'houzez'),
			'id' => 'search-sidebar',
			'description' => esc_html__('Widgets in this area will be shown in search result page.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Single Property', 'houzez'),
			'id' => 'single-property',
			'description' => esc_html__('Widgets in this area will be shown in single property sidebar.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Page Sidebar', 'houzez'),
			'id' => 'page-sidebar',
			'description' => esc_html__('Widgets in this area will be shown in page sidebar.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Agency Sidebar', 'houzez'),
			'id' => 'agency-sidebar',
			'description' => esc_html__('Widgets in this area will be shown in agencies template and agency detail page.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Agent Sidebar', 'houzez'),
			'id' => 'agent-sidebar',
			'description' => esc_html__('Widgets in this area will be shown in agents template and angent detail page.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Mobile Menu', 'houzez'),
			'id' => 'hz-mobile-menu',
			'description' => esc_html__('Widgets in this area will be shown in the mobile menu', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Custom Widget Area 1', 'houzez'),
			'id' => 'hz-custom-widget-area-1',
			'description' => esc_html__('You can assign this widget are to any page.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Custom Widget Area 2', 'houzez'),
			'id' => 'hz-custom-widget-area-2',
			'description' => esc_html__('You can assign this widget are to any page.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Custom Widget Area 3', 'houzez'),
			'id' => 'hz-custom-widget-area-3',
			'description' => esc_html__('You can assign this widget are to any page.', 'houzez'),
			'before_widget' => '<div id="%1$s" class="widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Footer Area 1', 'houzez'),
			'id' => 'footer-sidebar-1',
			'description' => esc_html__('Widgets in this area will be show in footer column one', 'houzez'),
			'before_widget' => '<div id="%1$s" class="footer-widget widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Footer Area 2', 'houzez'),
			'id' => 'footer-sidebar-2',
			'description' => esc_html__('Widgets in this area will be show in footer column two', 'houzez'),
			'before_widget' => '<div id="%1$s" class="footer-widget widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Footer Area 3', 'houzez'),
			'id' => 'footer-sidebar-3',
			'description' => esc_html__('Widgets in this area will be show in footer column three', 'houzez'),
			'before_widget' => '<div id="%1$s" class="footer-widget widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
		register_sidebar(array(
			'name' => esc_html__('Footer Area 4', 'houzez'),
			'id' => 'footer-sidebar-4',
			'description' => esc_html__('Widgets in this area will be show in footer column four', 'houzez'),
			'before_widget' => '<div id="%1$s" class="footer-widget widget widget-wrap mb-4 p-4 %2$s">',
			'after_widget' => '</div>',
			'before_title' => '<div class="widget-header"><h3 class="widget-title mb-4">',
			'after_title' => '</h3></div>',
		));
	}
}

/**
 *	---------------------------------------------------------------------
 *	Disable emoji scripts
 *	---------------------------------------------------------------------
 */
if( !function_exists('houzez_disable_emoji') ) {
	function houzez_disable_emoji() {
		if ( ! is_admin() && houzez_option( 'disable_emoji', 0 ) ) {
			remove_action('wp_head', 'print_emoji_detection_script', 7);
			remove_action('wp_print_styles', 'print_emoji_styles');
		}
	}
	houzez_disable_emoji();
}


/**
 *	---------------------------------------------------------------------
 *	Remove jQuery migrate.
 *	---------------------------------------------------------------------
 */
if( !function_exists('houzez_remove_jquery_migrate') ) {
	function houzez_remove_jquery_migrate( $scripts ) {
		if ( ! houzez_option( 'disable_jquery_migrate', 0 ) ) return;
		if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
			$script = $scripts->registered['jquery'];

			if ( $script->deps ) { // Check whether the script has any dependencies.
				$script->deps = array_diff( $script->deps, array(
					'jquery-migrate',
				) );
			}
		}
	}
	//add_action( 'wp_default_scripts', 'houzez_remove_jquery_migrate' );
}


if( !function_exists('houzez_js_async_attr')) {
	function houzez_js_async_attr($url){
	 
		# Do not add defer or async attribute to these scripts
		$scripts_to_exclude = array('jquery.js');
		
		//if ( is_user_logged_in() ) return $url;
		if ( is_admin() || houzez_is_dashboard() || is_preview() || houzez_option('defer_async_enabled', 0 ) == 0 ) return $url;
		
		foreach($scripts_to_exclude as $exclude_script){
		    if(true == strpos($url, $exclude_script ) )
		    return $url;    
		}
		 
		# Defer or async all remaining scripts not excluded above
		return str_replace( ' src', ' defer src', $url );
	}
	//add_filter( 'script_loader_tag', 'houzez_js_async_attr', 10 );
}

if( !function_exists('houzez_instantpage_script_loader_tag')) {
	function houzez_instantpage_script_loader_tag( $tag, $handle ) {
	  if ( 'houzez-instant-page' === $handle && houzez_option('preload_pages', 1) ) {
	    $tag = str_replace( 'text/javascript', 'module', $tag );
	  }
	  return $tag;
	}
	add_filter( 'script_loader_tag', 'houzez_instantpage_script_loader_tag', 10, 2 );
}

if(!function_exists('houzez_hide_admin_bar')) {
	function houzez_hide_admin_bar($bool) {
	  
	  if ( !current_user_can('administrator') && !is_admin() ) {
	  		return false;
	  } elseif ( houzez_is_dashboard() ) {
	    return false;
	  } else {
	    return $bool;
	  }
	}
	add_filter('show_admin_bar', 'houzez_hide_admin_bar');
}

if ( !function_exists( 'houzez_block_users' ) ) {

	add_action( 'admin_init', 'houzez_block_users' );

	function houzez_block_users() {
		$users_admin_access = houzez_option('users_admin_access');

		if( is_user_logged_in() && $users_admin_access && !houzez_is_demo() ) {
			
			if (is_admin() && !current_user_can('administrator') && !houzez_is_editor() && isset( $_GET['action'] ) != 'delete' && !(defined('DOING_AJAX') && DOING_AJAX)) {
				wp_die(esc_html("You don't have permission to access this page.", "Houzez"));
				exit;
			}
		}
	}

}

if( !function_exists('houzez_unset_default_templates') ) {
	function houzez_unset_default_templates( $templates ) {
		if( !is_admin() ) {
			return $templates;
		}
		$houzez_templates = houzez_option('houzez_templates');

		if( !empty($houzez_templates) ) {
			foreach ($houzez_templates as $template) {
				unset( $templates[$template] );
			}
		}
	    
	    return $templates;
	}
	add_filter( 'theme_page_templates', 'houzez_unset_default_templates' );
}

if(!function_exists('houzez_author_pre_get')) {
	function houzez_author_pre_get( $query ) {
	    if ( $query->is_author() && $query->is_main_query() && !is_admin() ) :
	        $query->set( 'posts_per_page', houzez_option('num_of_agent_listings', 10) );
	        $query->set( 'post_type', array('property') );
	    endif;
	}
	add_action( 'pre_get_posts', 'houzez_author_pre_get' );
}

add_action ('redux/options/houzez_options/saved', 'houzez_save_custom_options_for_cron');
if( ! function_exists('houzez_save_custom_options_for_cron') ) {
    function houzez_save_custom_options_for_cron() {

    	
        $insights_removal = houzez_option('insights_removal', '60');
        $custom_days = houzez_option('custom_days', '90');
        
        update_option('houzez_insights_removal', $insights_removal);
        update_option('houzez_custom_days', $custom_days);

    }
}


if( ! function_exists('houzez_update_existing_users_with_manager_role_once') ) {
	function houzez_update_existing_users_with_manager_role_once() {
	    // Check if the update has already been done
	    if (get_option('houzez_manager_role_updated')) {
	        return; // Exit if already run
	    }

	    // Fetch all users with the houzez_manager role
	    $args = [
	        'role' => 'houzez_manager'
	    ];
	    $users = get_users($args);

	    foreach ($users as $user) {
	        // Ensure each user has the houzez_manager role, which now has updated capabilities
	        $user->add_role('houzez_manager');
	    }

	    // Set an option to indicate the update has been run
	    update_option('houzez_manager_role_updated', true);
	}

	// Run the function to update users
	houzez_update_existing_users_with_manager_role_once();
}

/**
 * Remove unnecessary scripts and styles from dashboard pages
 */
if( ! function_exists('houzez_remove_frontend_assets_from_dashboard') ) {
	function houzez_remove_frontend_assets_from_dashboard() {
		if (!houzez_is_dashboard()) {
			return;
		}

		wp_dequeue_style('houzez-main');
	}
	add_action('wp_enqueue_scripts', 'houzez_remove_frontend_assets_from_dashboard', 100);
}

/**
 * Preload featured image on property detail pages for better LCP
 */
if( ! function_exists('houzez_preload_property_featured_image') ) {
	function houzez_preload_property_featured_image() {
		// Only on single property pages
		if ( ! is_singular('property') ) {
			return;
		}

		global $post;
		if ( ! $post ) {
			return;
		}

		// Get featured image
		$featured_image_id = get_post_thumbnail_id( $post->ID );
		if ( ! $featured_image_id ) {
			// Try to get first gallery image if no featured image
			$images_ids = get_post_meta( $post->ID, 'fave_property_images', false );
			if ( ! empty( $images_ids ) && is_array( $images_ids ) ) {
				$featured_image_id = $images_ids[0];
			}
		}

		if ( ! $featured_image_id ) {
			return;
		}

		// Get appropriate image size based on layout - use same dynamic size as gallery template
		$image_size = houzez_get_image_size_for('property_detail_v3-4');
		$image_data = wp_get_attachment_image_src( $featured_image_id, $image_size );

		if ( $image_data && isset( $image_data[0] ) ) {
			$image_url = $image_data[0];

			// Output simplified preload link tag for fastest LCP
			// No srcset to ensure browser loads exact image immediately
			echo '<link rel="preload" as="image" href="' . esc_url( $image_url ) . '" fetchpriority="high">' . "\n";
		}
	}
	add_action('wp_head', 'houzez_preload_property_featured_image', 1);
}

/**
 * One-time cleanup of legacy houzez_template_* options from wp_options.
 * These were previously used to cache individual template data but are no longer needed
 * since templates are now served from JSON files via the favethemes-api plugin.
 */
if ( ! function_exists( 'houzez_cleanup_legacy_template_options' ) ) {
	function houzez_cleanup_legacy_template_options() {
		if ( get_option( 'houzez_template_options_cleaned' ) ) {
			return;
		}

		global $wpdb;
		$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'houzez\_template\_%'" );

		delete_option( 'houzez_sync_progress' );
		delete_option( 'houzez_templates_last_sync' );

		update_option( 'houzez_template_options_cleaned', 1, false );
	}
	add_action( 'admin_init', 'houzez_cleanup_legacy_template_options' );
}
function houzez_agresif_cevirici($buffer) {
    // Arama Motoru Kelimeleri
    $buffer = str_replace('Type', 'Emlak Türü', $buffer);
    $buffer = str_replace('Bedrooms', 'Yatak odası', $buffer);
    $buffer = str_replace('Bathrooms', 'Banyolar', $buffer);
    $buffer = str_replace('Status', 'Durum', $buffer);
    $buffer = str_replace('Min. Area', 'Min. Alan', $buffer);
    $buffer = str_replace('All Status', 'Tüm Durumlar', $buffer);
    $buffer = str_replace('Enter Keyword', 'Referans No', $buffer);
    
    // Kullanıcı Paneli Kelimeleri
    $buffer = str_replace('Dashboard', 'Kontrol Paneli', $buffer);
    $buffer = str_replace('Favorite Properties', 'Favori İlanlarım', $buffer);
    $buffer = str_replace('Activities', 'Etkinlikler', $buffer);
    $buffer = str_replace('Insight', 'İstatistikler', $buffer);
    
    return $buffer;
}
function houzez_cevirici_baslat() { ob_start("houzez_agresif_cevirici"); }
function houzez_cevirici_bitir() { ob_end_flush(); }
add_action('init', 'houzez_cevirici_baslat');
if (class_exists('LiteSpeed_Cache_API')) { LiteSpeed_Cache_API::purge_all(); }
function houzez_javascript_cevirici_ekle() {
    ?>
    <script type="text/javascript">
    document.addEventListener("DOMContentLoaded", function() {
        var kelimeler = {
            "Type": "Emlak Türü",
            "Bedrooms": "Yatak odası",
            "Bathrooms": "Banyolar",
            "Status": "Durum",
            "Min. Area": "Min. Alan",
            "All Status": "Tüm Durumlar",
            "Enter Keyword": "Referans No",
            "Dashboard": "Kontrol Paneli",
            "Favorite Properties": "Favori İlanlarım",
            "Activities": "Etkinlikler",
            "Insight": "İstatistikler"
        };

        function metinleriDegistir(node) {
            if (node.nodeType === Node.TEXT_NODE) {
                var text = node.nodeValue.trim();
                if (kelimeler[text]) {
                    node.nodeValue = node.nodeValue.replace(text, kelimeler[text]);
                }
            } else {
                for (var i = 0; i < node.childNodes.length; i++) {
                    metinleriDegistir(node.childNodes[i]);
                }
            }
        }
        metinleriDegistir(document.body);
    });
    </script>
    <?php
}
add_action('wp_footer', 'houzez_javascript_cevirici_ekle', 999);
add_action('admin_footer', 'houzez_javascript_cevirici_ekle', 999);
add_filter('gettext', 'houzez_arama_motoru_kalanlari_turkcelestir', 20, 3);
function houzez_arama_motoru_kalanlari_turkcelestir($translated_text, $text, $domain) {
    if ($text == 'tip' || $text == 'Type') {
        return 'Emlak Türü';
    }
    if ($text == 'Enter Keyword...' || $text == 'Enter Keyword') {
        return 'Referans No / Kelime';
    }
    if ($text == 'Min. Area') {
        return 'Min. Alan';
    }
    if ($text == 'Max. Area') {
        return 'Max. Alan';
    }
    if ($text == 'Kuruluş yılı' || $text == 'Year Built') {
        return 'İnşa Yılı';
    }
    if ($text == 'Garaj' || $text == 'Garage') {
        return 'Garaj';
    }
    if ($text == 'Min. Land Area') {
        return 'Min. Arsa Alanı';
    }
    if ($text == 'Max. Land Area') {
        return 'Max. Arsa Alanı';
    }
    return $translated_text;
}


