<?php
/**
* Layout Functions
*
* @package GridFeel 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>
*/

function gridfeel_hide_footer_widgets() {
    $hide_footer_widgets = false;

    if ( gridfeel_get_option('hide_footer_widgets') ) {
        $hide_footer_widgets = true;
    }

    return apply_filters( 'gridfeel_hide_footer_widgets', $hide_footer_widgets );
}

function gridfeel_is_header_content_active() {
    $header_content_active = true;

    if ( gridfeel_get_option('hide_header_content') ) {
        $header_content_active = false;
    }

    return apply_filters( 'gridfeel_is_header_content_active', $header_content_active );
}

function gridfeel_is_primary_menu_active() {
    $primary_menu_active = true;

    if ( gridfeel_get_option('disable_primary_menu') ) {
        $primary_menu_active = false;
    }

    return apply_filters( 'gridfeel_is_primary_menu_active', $primary_menu_active );
}

function gridfeel_is_secondary_menu_active() {
    $secondary_menu_active = true;

    if ( gridfeel_get_option('disable_secondary_menu') ) {
        $secondary_menu_active = false;
    }

    return apply_filters( 'gridfeel_is_secondary_menu_active', $secondary_menu_active );
}

function gridfeel_is_secondary_menu_responsive() {
    $secondary_menu_responsive = true;

    return apply_filters( 'gridfeel_is_secondary_menu_responsive', $secondary_menu_responsive );
}

function gridfeel_is_sticky_menu_active() {
    $sticky_menu_active = true;

    if ( gridfeel_get_option('disable_sticky_menu') ) {
        $sticky_menu_active = false;
    }

    return apply_filters( 'gridfeel_is_sticky_menu_active', $sticky_menu_active );
}

function gridfeel_is_sticky_mobile_menu_active() {
    $sticky_mobile_menu_active = false;

    if ( gridfeel_get_option('enable_sticky_mobile_menu') ) {
        $sticky_mobile_menu_active = true;
    }

    return apply_filters( 'gridfeel_is_sticky_mobile_menu_active', $sticky_mobile_menu_active );
}

function gridfeel_social_buttons_location() {
    $social_buttons_location = 'secondary-menu';

    if ( gridfeel_get_option('social_buttons_location') ) {
        $social_buttons_location = gridfeel_get_option('social_buttons_location');
    }

   return apply_filters( 'gridfeel_social_buttons_location', $social_buttons_location );
}

function gridfeel_is_social_buttons_active() {
    $social_buttons_active = true;

    if ( gridfeel_get_option('hide_social_buttons') ) {
        $social_buttons_active = false;
    }

    return apply_filters( 'gridfeel_is_social_buttons_active', $social_buttons_active );
}

function gridfeel_is_sticky_sidebar_active() {
    $sticky_sidebar_active = true;

    if ( gridfeel_get_option('disable_sticky_sidebar') ) {
        $sticky_sidebar_active = false;
    }

    return apply_filters( 'gridfeel_is_sticky_sidebar_active', $sticky_sidebar_active );
}

function gridfeel_is_fitvids_active() {
    $fitvids_active = true;

    if ( gridfeel_get_option('disable_fitvids') ) {
        $fitvids_active = false;
    }

    return apply_filters( 'gridfeel_is_fitvids_active', $fitvids_active );
}

function gridfeel_is_backtotop_active() {
    $backtotop_active = true;

    if ( gridfeel_get_option('disable_backtotop') ) {
        $backtotop_active = false;
    }

    return apply_filters( 'gridfeel_is_backtotop_active', $backtotop_active );
}

function gridfeel_grid_item_height() {
    $grid_item_height = '220px';
    if ( gridfeel_get_option('grid_item_height') ) {
        $grid_item_height = gridfeel_get_option('grid_item_height');
    }

   return apply_filters( 'gridfeel_grid_item_height', $grid_item_height );
}

/**
 * Set the content width in pixels, based on the theme's design and stylesheet.
 *
 * Priority 0 to make it available to lower priority callbacks.
 *
 * @global int $content_width
 */
function gridfeel_content_width() {
    $content_width = 798;

    if ( is_page_template( array( 'template-full-width-page.php', 'template-full-width-page-sidebar.php', 'template-full-width-post.php', 'template-full-width-post-sidebar.php' ) ) ) {
       $content_width = 1422;
    }

    if ( is_404() ) {
        $content_width = 1422;
    }

    $GLOBALS['content_width'] = apply_filters( 'gridfeel_content_width', $content_width ); /* phpcs:ignore WPThemeReview.CoreFunctionality.PrefixAllGlobals.NonPrefixedVariableFound */
}
add_action( 'template_redirect', 'gridfeel_content_width', 0 );

function gridfeel_grid_thumb_position() {
   $thumb_position = 'top';
    if ( gridfeel_get_option('grid_thumb_position') ) {
        $thumb_position = gridfeel_get_option('grid_thumb_position');
    }
   return apply_filters( 'gridfeel_grid_thumb_position', $thumb_position );
}