<?php

/**
 * Next Property functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package NexProperty
 */

if ( ! defined( 'NEXPROPERTY_THEME_DIRECTORY' ) ) {
	define( 'NEXPROPERTY_THEME_DIRECTORY', get_template_directory() );
}

if ( ! defined( 'NEXPROPERTY_ASSETS_DIR_URI' ) ) {
	define( 'NEXPROPERTY_ASSETS_DIR_URI', get_template_directory_uri() . '/assets' );
}

if ( ! defined( 'NEXPROPERTY_ASSETS_DIR' ) ) {
	define( 'NEXPROPERTY_ASSETS_DIR', get_template_directory() . '/assets' );
}

if ( ! defined( 'NEXPROPERTY_THEME_VERSION' ) ) {
		define( 'NEXPROPERTY_THEME_VERSION', wp_get_theme( get_template() )->get('Version') );
}

require NEXPROPERTY_THEME_DIRECTORY . '/includes/autoload.php';


function nexproperty_custom_logo (){
    $return = false;
    if(get_theme_mod( 'custom_logo' )) {
        $custom_logo__url = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' ); 
        if (isset($custom_logo__url[0]) && substr_count($custom_logo__url[0], 'media/default.png') == 0) {
             $return = $custom_logo__url[0];
         }
    }
    return $return;
}

/**
 * Fix skip link focus in IE11.
 *
 * This does not enqueue the script because it is tiny and because it is only for IE11,
 * thus it does not warrant having an entire dedicated blocking script being loaded.
 *
 * @link https://git.io/vWdr2
 */
function nexproperty_skip_link_focus_fix() {
	// The following is minified via `terser --compress --mangle -- js/skip-link-focus-fix.js`.
	?>
	<script>
	/(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);
	</script>
	<?php
}
add_action( 'wp_print_footer_scripts', 'nexproperty_skip_link_focus_fix' );