<?php
/**
 * Theme setup.
 *
 * @package ALFASMART
 */

if (! defined('ABSPATH')) {
    exit;
}

define('ALFASMART_VERSION', '1.0.0');
define('ALFASMART_URI', get_template_directory_uri());
define('ALFASMART_DIR', get_template_directory());
define('ALFASMART_IMG_URI', ALFASMART_URI . '/assets/img/');

add_action('after_setup_theme', function () {
    load_theme_textdomain('alfasmart', ALFASMART_DIR . '/languages');

    add_theme_support('automatic-feed-links');
    add_theme_support('title-tag');
    add_theme_support('post-thumbnails');
    add_theme_support('responsive-embeds');
    add_theme_support('html5', array('search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script'));
    add_theme_support('custom-logo', array(
        'height'      => 100,
        'width'       => 300,
        'flex-height' => true,
        'flex-width'  => true,
    ));

    register_nav_menus(array(
        'primary'       => __('Primary Menu', 'alfasmart'),
        'footer'        => __('Footer Menu', 'alfasmart'),
        'main_screens'  => __('Main Screens', 'alfasmart'),
        'our_companies' => __('Our Companies', 'alfasmart'),
    ));
});

add_action('wp_head', function () {
    $favicon = alfasmart_get_option_image_url('favicon');

    if ($favicon) {
        printf('<link rel="icon" href="%s" type="image/x-icon">' . "\n", esc_url($favicon));
    }
}, 5);

add_filter('body_class', function ($classes) {
    if (! is_front_page()) {
        $classes[] = 'as-inner-page';
    }

    if (is_post_type_archive(array('companies', 'services'))) {
        $classes[] = 'as-archive-page';
    }

    if (is_page('contact')) {
        $classes[] = 'as-contact-page';
    }

    return $classes;
});

add_filter('wpcf7_autop_or_not', '__return_false');
