<?php
/**
* Css Classes Functions
*
* @package GridMini WordPress Theme
* @copyright Copyright (C) 2025 ThemesDNA
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
* @author ThemesDNA <themesdna@gmail.com>
*/

// Category ids in post class
function gridmini_category_id_class($classes) {
    global $post;
    foreach((get_the_category($post->ID)) as $category) {
        $classes[] = 'wpcat-' . $category->cat_ID . '-id';
    }
    return apply_filters( 'gridmini_category_id_class', $classes );
}
add_filter('post_class', 'gridmini_category_id_class');


// Adds custom classes to the array of body classes.
function gridmini_body_classes( $classes ) {
    // Adds a class of group-blog to blogs with more than 1 published author.
    if ( is_multi_author() ) {
        $classes[] = 'gridmini-group-blog';
    }

    if ( !(gridmini_get_option('disable_loading_animation')) ) {
        $classes[] = 'gridmini-animated gridmini-fadein';
    }

    $classes[] = 'gridmini-theme-is-active';

    if ( get_header_image() ) {
        $classes[] = 'gridmini-header-image-active';
    }

    if ( gridmini_get_option('header_image_cover') ) {
        $classes[] = 'gridmini-header-image-cover';
    }

    if ( has_custom_logo() ) {
        $classes[] = 'gridmini-custom-logo-active';
    }

    $classes[] = 'gridmini-layout-type-full';

    $classes[] = 'gridmini-masonry-inactive';

    if ( gridmini_get_option('disable_equal_height_grid_items') ) {
        $classes[] = 'gridmini-float-grid';
    } else {
        $classes[] = 'gridmini-flexbox-grid';
    }

    if ( is_singular() ) {
        if( is_single() ) {
            if ( gridmini_get_option('featured_media_under_post_title') ) {
                $classes[] = 'gridmini-single-media-under-title';
            }
        }
        if( is_page() ) {
            if ( gridmini_get_option('featured_media_under_page_title') ) {
                $classes[] = 'gridmini-single-media-under-title';
            }
        }

        if ( is_page_template( array( 'template-full-width-page.php', 'template-full-width-post.php' ) ) ) {
           $classes[] = 'gridmini-layout-full-width';
        } else {
            $classes[] = 'gridmini-layout-c-s1';
        }
    } else {
        $classes[] = 'gridmini-layout-full-width';
    }

    if ( !(gridmini_is_primary_menu_active()) ) {
        $classes[] = 'gridmini-header-full-active';
    } else {
        $classes[] = 'gridmini-header-menu-active';
    }

    if ( gridmini_get_option('hide_tagline') ) {
        $classes[] = 'gridmini-tagline-inactive';
    }

    if ( 'beside-title' === gridmini_get_option('logo_location') ) {
        $classes[] = 'gridmini-logo-beside-title';
    } elseif ( 'above-title' === gridmini_get_option('logo_location') ) {
        $classes[] = 'gridmini-logo-above-title';
    } else {
        $classes[] = 'gridmini-logo-above-title';
    }

    if ( gridmini_is_primary_menu_active() ) {
        $classes[] = 'gridmini-primary-menu-active';
    } else {
        $classes[] = 'gridmini-primary-menu-inactive';
    }
    $classes[] = 'gridmini-primary-mobile-menu-active';

    if ( gridmini_is_secondary_menu_active() ) {
        $classes[] = 'gridmini-secondary-menu-active';
    } else {
        $classes[] = 'gridmini-secondary-menu-inactive';
    }
    $classes[] = 'gridmini-secondary-mobile-menu-active';
    if ( gridmini_get_option('center_secondary_menu') ) {
        $classes[] = 'gridmini-secondary-menu-centered';
    }

    if ( 'before-header' === gridmini_secondary_menu_location() ) {
        $classes[] = 'gridmini-secondary-menu-before-header';
    } elseif ( 'after-header' === gridmini_secondary_menu_location() ) {
        $classes[] = 'gridmini-secondary-menu-after-header';
    } elseif ( 'before-footer' === gridmini_secondary_menu_location() ) {
        $classes[] = 'gridmini-secondary-menu-before-footer';
    } elseif ( 'after-footer' === gridmini_secondary_menu_location() ) {
        $classes[] = 'gridmini-secondary-menu-after-footer';
    } else {
        $classes[] = 'gridmini-secondary-menu-before-header';
    }

    if ( gridmini_is_social_buttons_active() ) {
        $classes[] = 'gridmini-social-buttons-active';
    } else {
        $classes[] = 'gridmini-social-buttons-inactive';
    }

    if ( !(gridmini_get_option('disable_table_colors')) ) {
        $classes[] = 'gridmini-table-css-active';
    }

    if ( gridmini_get_option('disable_responsive_grid_data') ) {
        $classes[] = 'gridmini-unresponsive-grid-data';
    } else {
        $classes[] = 'gridmini-responsive-grid-data';
    }

    if ( gridmini_get_option('no_underline_content_links') ) {
        $classes[] = 'gridmini-nouc-links';
    } else {
        $classes[] = 'gridmini-uc-links';
    }

    return apply_filters( 'gridmini_body_classes', $classes );
}
add_filter( 'body_class', 'gridmini_body_classes' );