<?php
/**
* Css Classes Functions
*
* @package GridRead 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 gridread_category_id_class($classes) {
    global $post;
    foreach((get_the_category($post->ID)) as $category) {
        $classes[] = 'wpcat-' . $category->cat_ID . '-id';
    }
    return apply_filters( 'gridread_category_id_class', $classes );
}
add_filter('post_class', 'gridread_category_id_class');


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

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

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

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

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

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

    $classes[] = 'gridread-layout-type-full';
    $classes[] = 'gridread-masonry-inactive';

    $classes[] = 'gridread-round-grid-posts';
    $classes[] = 'gridread-round-slider-posts';
    $classes[] = 'gridread-centered-grid';
    $classes[] = 'gridread-centered-slider';

    if ( !(is_singular()) ) {
        if ( gridread_get_option('featured_nongrid_media_under_post_title') ) {
            $classes[] = 'gridread-nongrid-media-under-title';
        }
    }

    if ( is_singular() ) {
        $classes[] = 'gridread-singular-page';
    } else {
        $classes[] = 'gridread-plural-page';
    }

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

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

    $classes[] = 'gridread-header-right-active';

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

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

    if ( gridread_is_primary_menu_active() ) {
        $classes[] = 'gridread-primary-menu-active';
    }
    $classes[] = 'gridread-primary-mobile-menu-active';
    if ( gridread_get_option('center_primary_menu') ) {
        $classes[] = 'gridread-primary-menu-centered';
    }

    if ( gridread_is_secondary_menu_active() ) {
        $classes[] = 'gridread-secondary-menu-active';
    }
    $classes[] = 'gridread-secondary-mobile-menu-active';
    if ( gridread_get_option('center_secondary_menu') ) {
        $classes[] = 'gridread-secondary-menu-centered';
    }

    $classes[] = 'gridread-responsive-grid-data';
    $classes[] = 'gridread-responsive-slider-data';

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

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