get( 'Version' );
// wp_enqueue_style( 'twentytwenty-style', get_stylesheet_uri(), array(), $theme_version );
wp_style_add_data( 'avantex-style-css', 'rtl', 'replace' );
// Add print CSS.
wp_enqueue_style( 'twentytwenty-print-style', get_template_directory_uri() . '/theme-menu/print.css', null, $theme_version, 'print' );
}
add_action( 'wp_enqueue_scripts', 'avantex_register_styles' );
/**
* Register and Enqueue Scripts.
*/
function avantex_register_scripts() {
$theme_version = wp_get_theme()->get( 'Version' );
if ( ( ! is_admin() ) && is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
wp_enqueue_script( 'avantex-js', get_template_directory_uri() . '/theme-menu/inc/index.js', array(), $theme_version, false );
wp_script_add_data( 'avantex-js', 'async', true );
}
add_action( 'wp_enqueue_scripts', 'avantex_register_scripts' );
/**
* 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 avantex_skip_link_focus_fix() {
// The following is minified via `terser --compress --mangle -- assets/js/skip-link-focus-fix.js`.
?>
__( 'Desktop Horizontal Menu', 'avantex' ),
//'expanded' => __( 'Desktop Expanded Menu', 'avantex' ),
//'mobile' => __( 'Mobile Menu', 'avantex' ),
'footer' => __( 'Footer Menu', 'avantex' ),
//'social' => __( 'Social Menu', 'avantex' ),
);
register_nav_menus( $locations );
}
add_action( 'init', 'avantex_menus' );
/**
* Get the information about the logo.
*
* @param string $html The HTML output from get_custom_logo (core function).
* @return string
*/
function avantex_get_custom_logo( $html ) {
$logo_id = get_theme_mod( 'custom_logo' );
if ( ! $logo_id ) {
return $html;
}
$logo = wp_get_attachment_image_src( $logo_id, 'full' );
if ( $logo ) {
// For clarity.
$logo_width = esc_attr( $logo[1] );
$logo_height = esc_attr( $logo[2] );
// If the retina logo setting is active, reduce the width/height by half.
if ( get_theme_mod( 'retina_logo', false ) ) {
$logo_width = floor( $logo_width / 2 );
$logo_height = floor( $logo_height / 2 );
$search = array(
'/width=\"\d+\"/iU',
'/height=\"\d+\"/iU',
);
$replace = array(
"width=\"{$logo_width}\"",
"height=\"{$logo_height}\"",
);
// Add a style attribute with the height, or append the height to the style attribute if the style attribute already exists.
if ( strpos( $html, ' style=' ) === false ) {
$search[] = '/(src=)/';
$replace[] = "style=\"height: {$logo_height}px;\" src=";
} else {
$search[] = '/(style="[^"]*)/';
$replace[] = "$1 height: {$logo_height}px;";
}
$html = preg_replace( $search, $replace, $html );
}
}
return $html;
}
add_filter( 'get_custom_logo', 'avantex_get_custom_logo' );
if ( ! function_exists( 'wp_body_open' ) ) {
/**
* Shim for wp_body_open, ensuring backward compatibility with versions of WordPress older than 5.2.
*/
function wp_body_open() {
do_action( 'wp_body_open' );
}
}
/**
* Include a skip to content link at the top of the page so that users can bypass the menu.
*/
function avantex_skip_link() {
echo '' . __( 'Skip to the content', 'avantex' ) . '';
}
add_action( 'wp_body_open', 'avantex_skip_link', 5 );