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

/**
 * This function return a value of given theme option name from database.
 *
 * @since 1.0.0
 *
 * @param string $option Theme option to return.
 * @return mixed The value of theme option.
 */
function gridflex_get_option($option) {
    $gridflex_options = get_option('gridflex_options');
    if ((is_array($gridflex_options)) && (array_key_exists($option, $gridflex_options))) {
        return $gridflex_options[$option];
    }
    else {
        return '';
    }
}

if ( ! function_exists( 'gridflex_setup' ) ) :
/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which
 * runs before the init hook. The init hook is too late for some features, such
 * as indicating support for post thumbnails.
 */
function gridflex_setup() {
    
    global $wp_version;

    /*
     * Make theme available for translation.
     * Translations can be filed in the /languages/ directory.
     * If you're building a theme based on GridFlex, use a find and replace
     * to change 'gridflex' to the name of your theme in all the template files.
     */
    load_theme_textdomain( 'gridflex', get_template_directory() . '/languages' );

    // Add default posts and comments RSS feed links to head.
    add_theme_support( 'automatic-feed-links' );

    /*
     * Let WordPress manage the document title.
     * By adding theme support, we declare that this theme does not use a
     * hard-coded <title> tag in the document head, and expect WordPress to
     * provide it for us.
     */
    add_theme_support( 'title-tag' );

    /*
     * Enable support for Post Thumbnails on posts and pages.
     *
     * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
     */
    add_theme_support( 'post-thumbnails' );

    if ( function_exists( 'add_image_size' ) ) {
        add_image_size( 'gridflex-1422w-autoh-image', 1422, 9999, false );
        add_image_size( 'gridflex-1074w-autoh-image', 1074, 9999, false );
        add_image_size( 'gridflex-360w-300h-image', 360, 300, true );
    }

    // This theme uses wp_nav_menu() in one location.
    register_nav_menus( array(
    'primary' => esc_html__('Primary Menu', 'gridflex'),
    'secondary' => esc_html__('Secondary Menu', 'gridflex')
    ) );

    /*
     * Switch default core markup for search form, comment form, and comments
     * to output valid HTML5.
     */
    $markup = array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'navigation-widgets' );
    add_theme_support( 'html5', $markup );

    add_theme_support( 'custom-logo', array(
        'height'      => 37,
        'width'       => 280,
        'flex-height' => true,
        'flex-width'  => true,
        'header-text' => array( 'site-title', 'site-description' ),
    ) );

    // Support for Custom Header
    add_theme_support( 'custom-header', apply_filters( 'gridflex_custom_header_args', array(
    'default-image'          => '',
    'default-text-color'     => '000000',
    'width'                  => 1920,
    'height'                 => 400,
    'flex-width'            => true,
    'flex-height'            => true,
    'wp-head-callback'       => 'gridflex_header_style',
    'uploads'                => true,
    ) ) );

    // Set up the WordPress core custom background feature.
    $background_args = array(
            'default-color'          => 'e6e6e6',
            'default-image'          => get_template_directory_uri() .'/assets/images/background.png',
            //'default-image'          => '',
            'default-repeat'         => 'repeat',
            'default-position-x'     => 'left',
            'default-position-y'     => 'top',
            'default-size'     => 'auto',
            'default-attachment'     => 'fixed',
            'wp-head-callback'       => '_custom_background_cb',
            'admin-head-callback'    => 'admin_head_callback_func',
            'admin-preview-callback' => 'admin_preview_callback_func',
    );
    add_theme_support( 'custom-background', apply_filters( 'gridflex_custom_background_args', $background_args) );

    // Support for Custom Editor Style
    add_editor_style( 'assets/css/editor-style.css' );

    // Add support for responsive embedded content.
    add_theme_support( 'responsive-embeds' );

    // Add support for Block Styles.
    add_theme_support( 'wp-block-styles' );

    if ( !(gridflex_get_option('enable_widgets_block_editor')) ) {
        remove_theme_support( 'widgets-block-editor' );
    }

}
endif;
add_action( 'after_setup_theme', 'gridflex_setup' );


/**
* Layout Functions
*/

function gridflex_hide_footer_widgets() {
    $hide_footer_widgets = false;

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

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

function gridflex_is_header_content_active() {
    $header_content_active = true;

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

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

function gridflex_is_primary_menu_active() {
    $primary_menu_active = true;

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

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

function gridflex_is_secondary_menu_active() {
    $secondary_menu_active = true;

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

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

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

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

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

function gridflex_is_social_buttons_active() {
    $social_buttons_active = true;

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

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

function gridflex_is_fitvids_active() {
    $fitvids_active = false;

    if ( gridflex_get_option('enable_fitvids') ) {
        $fitvids_active = true;
    }

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

function gridflex_is_backtotop_active() {
    $backtotop_active = true;

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

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

/**
 * 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 gridflex_content_width() {
    $content_width = 1074;

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

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


/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/

function gridflex_widgets_init() {

register_sidebar(array(
    'id' => 'gridflex-header-ad',
    'name' => esc_html__( 'Header Right Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located on the right side of the header of your web page. You can drag and drop a "Custom HTML" widget into this widget area and add your 728x90 banner ad code into that widget. You need to select "Header Layout" as "Logo + Header Banner" from theme options to display this widget area.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-header-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridflex-widget-title">',
    'after_title' => '</h2>'));

register_sidebar(array(
    'id' => 'gridflex-sidebar-one',
    'name' => esc_html__( 'Sidebar 1 Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located on the left-hand side of your web page.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-side-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-sidebar-two',
    'name' => esc_html__( 'Sidebar 2 Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located on the right-hand side of your web page.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-side-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-home-fullwidth-widgets',
    'name' => esc_html__( 'Top Full Width Widgets (Default HomePage)', 'gridflex' ),
    'description' => esc_html__( 'This full-width widget area is located after the header of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-fullwidth-widgets',
    'name' => esc_html__( 'Top Full Width Widgets (Everywhere)', 'gridflex' ),
    'description' => esc_html__( 'This full-width widget area is located after the header of your website. Widgets of this widget area are displayed on every page of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-home-top-widgets',
    'name' => esc_html__( 'Above Content Widgets (Default HomePage)', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located at the top of the main content (above posts) of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-top-widgets',
    'name' => esc_html__( 'Above Content Widgets (Everywhere)', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located at the top of the main content (above posts) of your website. Widgets of this widget area are displayed on every page of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-home-bottom-widgets',
    'name' => esc_html__( 'Below Content Widgets (Default HomePage)', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located at the bottom of the main content (below posts) of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-bottom-widgets',
    'name' => esc_html__( 'Below Content Widgets (Everywhere)', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located at the bottom of the main content (below posts) of your website. Widgets of this widget area are displayed on every page of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-home-fullwidth-bottom-widgets',
    'name' => esc_html__( 'Bottom Full Width Widgets (Default HomePage)', 'gridflex' ),
    'description' => esc_html__( 'This full-width widget area is located before the footer of your website. Widgets of this widget area are displayed on the default homepage of your website (when you are showing your latest posts on homepage).', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-fullwidth-bottom-widgets',
    'name' => esc_html__( 'Bottom Full Width Widgets (Everywhere)', 'gridflex' ),
    'description' => esc_html__( 'This full-width widget area is located before the footer of your website. Widgets of this widget area are displayed on every page of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-single-post-bottom-widgets',
    'name' => esc_html__( 'Single Post Bottom Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located at the bottom of single post of any post type (except attachments and pages).', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

register_sidebar(array(
    'id' => 'gridflex-top-footer',
    'name' => esc_html__( 'Footer Top Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located on the top of the footer of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridflex-footer-1',
    'name' => esc_html__( 'Footer 1 Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is the column 1 of the footer of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridflex-footer-2',
    'name' => esc_html__( 'Footer 2 Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is the column 2 of the footer of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridflex-footer-3',
    'name' => esc_html__( 'Footer 3 Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is the column 3 of the footer of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridflex-footer-4',
    'name' => esc_html__( 'Footer 4 Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is the column 4 of the footer of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridflex-footer-5',
    'name' => esc_html__( 'Footer 5 Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is the column 5 of the footer of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridflex-bottom-footer',
    'name' => esc_html__( 'Footer Bottom Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located on the bottom of the footer of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-footer-widget widget %2$s">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2>'));

register_sidebar(array(
    'id' => 'gridflex-404-widgets',
    'name' => esc_html__( '404 Page Widgets', 'gridflex' ),
    'description' => esc_html__( 'This widget area is located on the 404(not found) page of your website.', 'gridflex' ),
    'before_widget' => '<div id="%1$s" class="gridflex-main-widget widget gridflex-widget-box %2$s"><div class="gridflex-widget-box-inside">',
    'after_widget' => '</div></div>',
    'before_title' => '<div class="gridflex-widget-header"><div class="gridflex-widget-header-inside"><h2 class="gridflex-widget-title"><span class="gridflex-widget-title-inside">',
    'after_title' => '</span></h2></div></div>'));

}
add_action( 'widgets_init', 'gridflex_widgets_init' );


function gridflex_sidebar_one_widgets() {
    dynamic_sidebar( 'gridflex-sidebar-one' );
}

function gridflex_sidebar_two_widgets() {
    dynamic_sidebar( 'gridflex-sidebar-two' );
}

function gridflex_top_wide_widgets() { ?>

<?php if ( is_active_sidebar( 'gridflex-home-fullwidth-widgets' ) || is_active_sidebar( 'gridflex-fullwidth-widgets' ) ) : ?>
<div class="gridflex-outer-wrapper">
<div class="gridflex-top-wrapper-outer gridflex-clearfix">
<div class="gridflex-featured-posts-area gridflex-top-wrapper gridflex-clearfix">
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridflex-home-fullwidth-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridflex-fullwidth-widgets' ); ?>
</div>
</div>
</div>
<?php endif; ?>

<?php }


function gridflex_bottom_wide_widgets() { ?>

<?php if ( is_active_sidebar( 'gridflex-home-fullwidth-bottom-widgets' ) || is_active_sidebar( 'gridflex-fullwidth-bottom-widgets' ) ) : ?>
<div class="gridflex-outer-wrapper">
<div class="gridflex-bottom-wrapper-outer gridflex-clearfix">
<div class="gridflex-featured-posts-area gridflex-bottom-wrapper gridflex-clearfix">
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridflex-home-fullwidth-bottom-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridflex-fullwidth-bottom-widgets' ); ?>
</div>
</div>
</div>
<?php endif; ?>

<?php }


function gridflex_top_widgets() { ?>

<?php if ( is_active_sidebar( 'gridflex-home-top-widgets' ) || is_active_sidebar( 'gridflex-top-widgets' ) ) : ?>
<div class="gridflex-featured-posts-area gridflex-featured-posts-area-top gridflex-clearfix">
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridflex-home-top-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridflex-top-widgets' ); ?>
</div>
<?php endif; ?>

<?php }


function gridflex_bottom_widgets() { ?>

<?php if ( is_active_sidebar( 'gridflex-home-bottom-widgets' ) || is_active_sidebar( 'gridflex-bottom-widgets' ) ) : ?>
<div class='gridflex-featured-posts-area gridflex-featured-posts-area-bottom gridflex-clearfix'>
<?php if ( is_front_page() && is_home() && !is_paged() ) { ?>
<?php dynamic_sidebar( 'gridflex-home-bottom-widgets' ); ?>
<?php } ?>

<?php dynamic_sidebar( 'gridflex-bottom-widgets' ); ?>
</div>
<?php endif; ?>

<?php }


function gridflex_404_widgets() { ?>

<?php if ( is_active_sidebar( 'gridflex-404-widgets' ) ) : ?>
<div class="gridflex-featured-posts-area gridflex-featured-posts-area-top gridflex-clearfix">
<?php dynamic_sidebar( 'gridflex-404-widgets' ); ?>
</div>
<?php endif; ?>

<?php }


function gridflex_post_bottom_widgets() {
    if ( is_singular() ) {
        global $post;
        if ( is_active_sidebar( 'gridflex-single-post-bottom-widgets' ) ) : ?>
            <div class="gridflex-featured-posts-area gridflex-clearfix">
            <?php dynamic_sidebar( 'gridflex-single-post-bottom-widgets' ); ?>
            </div>
        <?php endif;
    }
}


/**
* Social buttons
*/

function gridflex_header_social_buttons() { ?>

<div class='gridflex-social-icons'>
    <?php if ( gridflex_get_option('twitterlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('twitterlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-twitter" aria-label="<?php esc_attr_e('X Button','gridflex'); ?>"><i class="fab fa-x-twitter" aria-hidden="true" title="<?php esc_attr_e('X','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('facebooklink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('facebooklink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-facebook" aria-label="<?php esc_attr_e('Facebook Button','gridflex'); ?>"><i class="fab fa-facebook-f" aria-hidden="true" title="<?php esc_attr_e('Facebook','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('threadslink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('threadslink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-threads" aria-label="<?php esc_attr_e('Threads Button','gridflex'); ?>"><i class="fab fa-threads" aria-hidden="true" title="<?php esc_attr_e('Threads','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('pinterestlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('pinterestlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-pinterest" aria-label="<?php esc_attr_e('Pinterest Button','gridflex'); ?>"><i class="fab fa-pinterest" aria-hidden="true" title="<?php esc_attr_e('Pinterest','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('linkedinlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('linkedinlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-linkedin" aria-label="<?php esc_attr_e('Linkedin Button','gridflex'); ?>"><i class="fab fa-linkedin-in" aria-hidden="true" title="<?php esc_attr_e('Linkedin','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('instagramlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('instagramlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-instagram" aria-label="<?php esc_attr_e('Instagram Button','gridflex'); ?>"><i class="fab fa-instagram" aria-hidden="true" title="<?php esc_attr_e('Instagram','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('flickrlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('flickrlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-flickr" aria-label="<?php esc_attr_e('Flickr Button','gridflex'); ?>"><i class="fab fa-flickr" aria-hidden="true" title="<?php esc_attr_e('Flickr','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('youtubelink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('youtubelink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-youtube" aria-label="<?php esc_attr_e('Youtube Button','gridflex'); ?>"><i class="fab fa-youtube" aria-hidden="true" title="<?php esc_attr_e('Youtube','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('vimeolink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('vimeolink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-vimeo" aria-label="<?php esc_attr_e('Vimeo Button','gridflex'); ?>"><i class="fab fa-vimeo-v" aria-hidden="true" title="<?php esc_attr_e('Vimeo','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('soundcloudlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('soundcloudlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-soundcloud" aria-label="<?php esc_attr_e('SoundCloud Button','gridflex'); ?>"><i class="fab fa-soundcloud" aria-hidden="true" title="<?php esc_attr_e('SoundCloud','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('messengerlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('messengerlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-messenger" aria-label="<?php esc_attr_e('Messenger Button','gridflex'); ?>"><i class="fab fa-facebook-messenger" aria-hidden="true" title="<?php esc_attr_e('Messenger','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('whatsapplink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('whatsapplink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-whatsapp" aria-label="<?php esc_attr_e('WhatsApp Button','gridflex'); ?>"><i class="fab fa-whatsapp" aria-hidden="true" title="<?php esc_attr_e('WhatsApp','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('tiktoklink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('tiktoklink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-tiktok" aria-label="<?php esc_attr_e('TikTok Button','gridflex'); ?>"><i class="fab fa-tiktok" aria-hidden="true" title="<?php esc_attr_e('TikTok','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('lastfmlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('lastfmlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-lastfm" aria-label="<?php esc_attr_e('Lastfm Button','gridflex'); ?>"><i class="fab fa-lastfm" aria-hidden="true" title="<?php esc_attr_e('Lastfm','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('mediumlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('mediumlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-medium" aria-label="<?php esc_attr_e('Medium Button','gridflex'); ?>"><i class="fab fa-medium-m" aria-hidden="true" title="<?php esc_attr_e('Medium','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('githublink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('githublink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-github" aria-label="<?php esc_attr_e('Github Button','gridflex'); ?>"><i class="fab fa-github" aria-hidden="true" title="<?php esc_attr_e('Github','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('bitbucketlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('bitbucketlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-bitbucket" aria-label="<?php esc_attr_e('Bitbucket Button','gridflex'); ?>"><i class="fab fa-bitbucket" aria-hidden="true" title="<?php esc_attr_e('Bitbucket','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('tumblrlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('tumblrlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-tumblr" aria-label="<?php esc_attr_e('Tumblr Button','gridflex'); ?>"><i class="fab fa-tumblr" aria-hidden="true" title="<?php esc_attr_e('Tumblr','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('digglink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('digglink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-digg" aria-label="<?php esc_attr_e('Digg Button','gridflex'); ?>"><i class="fab fa-digg" aria-hidden="true" title="<?php esc_attr_e('Digg','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('deliciouslink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('deliciouslink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-delicious" aria-label="<?php esc_attr_e('Delicious Button','gridflex'); ?>"><i class="fab fa-delicious" aria-hidden="true" title="<?php esc_attr_e('Delicious','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('stumblelink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('stumblelink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-stumbleupon" aria-label="<?php esc_attr_e('Stumbleupon Button','gridflex'); ?>"><i class="fab fa-stumbleupon" aria-hidden="true" title="<?php esc_attr_e('Stumbleupon','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('mixlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('mixlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-mix" aria-label="<?php esc_attr_e('Mix Button','gridflex'); ?>"><i class="fab fa-mix" aria-hidden="true" title="<?php esc_attr_e('Mix','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('redditlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('redditlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-reddit" aria-label="<?php esc_attr_e('Reddit Button','gridflex'); ?>"><i class="fab fa-reddit" aria-hidden="true" title="<?php esc_attr_e('Reddit','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('dribbblelink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('dribbblelink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-dribbble" aria-label="<?php esc_attr_e('Dribbble Button','gridflex'); ?>"><i class="fab fa-dribbble" aria-hidden="true" title="<?php esc_attr_e('Dribbble','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('flipboardlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('flipboardlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-flipboard" aria-label="<?php esc_attr_e('Flipboard Button','gridflex'); ?>"><i class="fab fa-flipboard" aria-hidden="true" title="<?php esc_attr_e('Flipboard','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('bloggerlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('bloggerlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-blogger" aria-label="<?php esc_attr_e('Blogger Button','gridflex'); ?>"><i class="fab fa-blogger" aria-hidden="true" title="<?php esc_attr_e('Blogger','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('etsylink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('etsylink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-etsy" aria-label="<?php esc_attr_e('Etsy Button','gridflex'); ?>"><i class="fab fa-etsy" aria-hidden="true" title="<?php esc_attr_e('Etsy','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('behancelink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('behancelink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-behance" aria-label="<?php esc_attr_e('Behance Button','gridflex'); ?>"><i class="fab fa-behance" aria-hidden="true" title="<?php esc_attr_e('Behance','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('amazonlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('amazonlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-amazon" aria-label="<?php esc_attr_e('Amazon Button','gridflex'); ?>"><i class="fab fa-amazon" aria-hidden="true" title="<?php esc_attr_e('Amazon','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('meetuplink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('meetuplink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-meetup" aria-label="<?php esc_attr_e('Meetup Button','gridflex'); ?>"><i class="fab fa-meetup" aria-hidden="true" title="<?php esc_attr_e('Meetup','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('mixcloudlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('mixcloudlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-mixcloud" aria-label="<?php esc_attr_e('Mixcloud Button','gridflex'); ?>"><i class="fab fa-mixcloud" aria-hidden="true" title="<?php esc_attr_e('Mixcloud','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('slacklink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('slacklink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-slack" aria-label="<?php esc_attr_e('Slack Button','gridflex'); ?>"><i class="fab fa-slack" aria-hidden="true" title="<?php esc_attr_e('Slack','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('snapchatlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('snapchatlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-snapchat" aria-label="<?php esc_attr_e('Snapchat Button','gridflex'); ?>"><i class="fab fa-snapchat" aria-hidden="true" title="<?php esc_attr_e('Snapchat','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('spotifylink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('spotifylink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-spotify" aria-label="<?php esc_attr_e('Spotify Button','gridflex'); ?>"><i class="fab fa-spotify" aria-hidden="true" title="<?php esc_attr_e('Spotify','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('yelplink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('yelplink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-yelp" aria-label="<?php esc_attr_e('Yelp Button','gridflex'); ?>"><i class="fab fa-yelp" aria-hidden="true" title="<?php esc_attr_e('Yelp','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('wordpresslink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('wordpresslink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-wordpress" aria-label="<?php esc_attr_e('WordPress Button','gridflex'); ?>"><i class="fab fa-wordpress" aria-hidden="true" title="<?php esc_attr_e('WordPress','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('twitchlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('twitchlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-twitch" aria-label="<?php esc_attr_e('Twitch Button','gridflex'); ?>"><i class="fab fa-twitch" aria-hidden="true" title="<?php esc_attr_e('Twitch','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('telegramlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('telegramlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-telegram" aria-label="<?php esc_attr_e('Telegram Button','gridflex'); ?>"><i class="fab fa-telegram" aria-hidden="true" title="<?php esc_attr_e('Telegram','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('bandcamplink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('bandcamplink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-bandcamp" aria-label="<?php esc_attr_e('Bandcamp Button','gridflex'); ?>"><i class="fab fa-bandcamp" aria-hidden="true" title="<?php esc_attr_e('Bandcamp','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('quoralink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('quoralink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-quora" aria-label="<?php esc_attr_e('Quora Button','gridflex'); ?>"><i class="fab fa-quora" aria-hidden="true" title="<?php esc_attr_e('Quora','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('foursquarelink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('foursquarelink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-foursquare" aria-label="<?php esc_attr_e('Foursquare Button','gridflex'); ?>"><i class="fab fa-foursquare" aria-hidden="true" title="<?php esc_attr_e('Foursquare','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('deviantartlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('deviantartlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-deviantart" aria-label="<?php esc_attr_e('DeviantArt Button','gridflex'); ?>"><i class="fab fa-deviantart" aria-hidden="true" title="<?php esc_attr_e('DeviantArt','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('imdblink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('imdblink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-imdb" aria-label="<?php esc_attr_e('IMDB Button','gridflex'); ?>"><i class="fab fa-imdb" aria-hidden="true" title="<?php esc_attr_e('IMDB','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('vklink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('vklink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-vk" aria-label="<?php esc_attr_e('VK Button','gridflex'); ?>"><i class="fab fa-vk" aria-hidden="true" title="<?php esc_attr_e('VK','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('codepenlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('codepenlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-codepen" aria-label="<?php esc_attr_e('Codepen Button','gridflex'); ?>"><i class="fab fa-codepen" aria-hidden="true" title="<?php esc_attr_e('Codepen','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('jsfiddlelink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('jsfiddlelink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-jsfiddle" aria-label="<?php esc_attr_e('JSFiddle Button','gridflex'); ?>"><i class="fab fa-jsfiddle" aria-hidden="true" title="<?php esc_attr_e('JSFiddle','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('stackoverflowlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('stackoverflowlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-stackoverflow" aria-label="<?php esc_attr_e('Stack Overflow Button','gridflex'); ?>"><i class="fab fa-stack-overflow" aria-hidden="true" title="<?php esc_attr_e('Stack Overflow','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('stackexchangelink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('stackexchangelink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-stackexchange" aria-label="<?php esc_attr_e('Stack Exchange Button','gridflex'); ?>"><i class="fab fa-stack-exchange" aria-hidden="true" title="<?php esc_attr_e('Stack Exchange','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('bsalink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('bsalink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-buysellads" aria-label="<?php esc_attr_e('BuySellAds Button','gridflex'); ?>"><i class="fab fa-buysellads" aria-hidden="true" title="<?php esc_attr_e('BuySellAds','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('web500pxlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('web500pxlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-web500px" aria-label="<?php esc_attr_e('500px Button','gridflex'); ?>"><i class="fab fa-500px" aria-hidden="true" title="<?php esc_attr_e('500px','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('ellolink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('ellolink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-ello" aria-label="<?php esc_attr_e('Ello Button','gridflex'); ?>"><i class="fab fa-ello" aria-hidden="true" title="<?php esc_attr_e('Ello','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('discordlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('discordlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-discord" aria-label="<?php esc_attr_e('Discord Button','gridflex'); ?>"><i class="fab fa-discord" aria-hidden="true" title="<?php esc_attr_e('Discord','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('goodreadslink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('goodreadslink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-goodreads" aria-label="<?php esc_attr_e('Goodreads Button','gridflex'); ?>"><i class="fab fa-goodreads" aria-hidden="true" title="<?php esc_attr_e('Goodreads','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('odnoklassnikilink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('odnoklassnikilink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-odnoklassniki" aria-label="<?php esc_attr_e('Odnoklassniki Button','gridflex'); ?>"><i class="fab fa-odnoklassniki" aria-hidden="true" title="<?php esc_attr_e('Odnoklassniki','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('houzzlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('houzzlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-houzz" aria-label="<?php esc_attr_e('Houzz Button','gridflex'); ?>"><i class="fab fa-houzz" aria-hidden="true" title="<?php esc_attr_e('Houzz','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('pocketlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('pocketlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-pocket" aria-label="<?php esc_attr_e('Pocket Button','gridflex'); ?>"><i class="fab fa-get-pocket" aria-hidden="true" title="<?php esc_attr_e('Pocket','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('xinglink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('xinglink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-xing" aria-label="<?php esc_attr_e('XING Button','gridflex'); ?>"><i class="fab fa-xing" aria-hidden="true" title="<?php esc_attr_e('XING','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('mastodonlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('mastodonlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-mastodon" aria-label="<?php esc_attr_e('Mastodon Button','gridflex'); ?>"><i class="fab fa-mastodon" aria-hidden="true" title="<?php esc_attr_e('Mastodon','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('googleplaylink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('googleplaylink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-googleplay" aria-label="<?php esc_attr_e('Google Play Button','gridflex'); ?>"><i class="fab fa-google-play" aria-hidden="true" title="<?php esc_attr_e('Google Play','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('slidesharelink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('slidesharelink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-slideshare" aria-label="<?php esc_attr_e('SlideShare Button','gridflex'); ?>"><i class="fab fa-slideshare" aria-hidden="true" title="<?php esc_attr_e('SlideShare','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('dropboxlink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('dropboxlink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-dropbox" aria-label="<?php esc_attr_e('Dropbox Button','gridflex'); ?>"><i class="fab fa-dropbox" aria-hidden="true" title="<?php esc_attr_e('Dropbox','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('paypallink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('paypallink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-paypal" aria-label="<?php esc_attr_e('PayPal Button','gridflex'); ?>"><i class="fab fa-paypal" aria-hidden="true" title="<?php esc_attr_e('PayPal','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('viadeolink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('viadeolink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-viadeo" aria-label="<?php esc_attr_e('Viadeo Button','gridflex'); ?>"><i class="fab fa-viadeo" aria-hidden="true" title="<?php esc_attr_e('Viadeo','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('wikipedialink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('wikipedialink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-wikipedia" aria-label="<?php esc_attr_e('Wikipedia Button','gridflex'); ?>"><i class="fab fa-wikipedia-w" aria-hidden="true" title="<?php esc_attr_e('Wikipedia','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('skypeusername') ) : ?>
            <a href="skype:<?php echo esc_html( gridflex_get_option('skypeusername') ); ?>?chat" class="gridflex-social-icon-skype" aria-label="<?php esc_attr_e('Skype Button','gridflex'); ?>"><i class="fab fa-skype" aria-hidden="true" title="<?php esc_attr_e('Skype','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('emailaddress') ) : ?>
            <a href="mailto:<?php echo esc_html( gridflex_get_option('emailaddress') ); ?>" class="gridflex-social-icon-email" aria-label="<?php esc_attr_e('Email Us Button','gridflex'); ?>"><i class="far fa-envelope" aria-hidden="true" title="<?php esc_attr_e('Email Us','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('rsslink') ) : ?>
            <a href="<?php echo esc_url( gridflex_get_option('rsslink') ); ?>" target="_blank" rel="nofollow" class="gridflex-social-icon-rss" aria-label="<?php esc_attr_e('RSS Button','gridflex'); ?>"><i class="fas fa-rss" aria-hidden="true" title="<?php esc_attr_e('RSS','gridflex'); ?>"></i></a><?php endif; ?>
    <?php if ( gridflex_get_option('show_login_button') ) { ?><?php if (is_user_logged_in()) : ?><a href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>" class="gridflex-social-icon-login" aria-label="<?php esc_attr_e( 'Logout Button', 'gridflex' ); ?>"><i class="fas fa-sign-out-alt" aria-hidden="true" title="<?php esc_attr_e( 'Logout Button', 'gridflex' ); ?>"></i></a><?php else : ?><a href="<?php echo esc_url( wp_login_url( get_permalink() ) ); ?>" class="gridflex-social-icon-login" aria-label="<?php esc_attr_e( 'Login / Register', 'gridflex' ); ?>"><i class="fas fa-sign-in-alt" aria-hidden="true" title="<?php esc_attr_e( 'Login / Register Button', 'gridflex' ); ?>"></i></a><?php endif;?><?php } ?>
    <?php if ( !(gridflex_get_option('hide_search_button')) ) { ?><a href="<?php echo esc_url( '#' ); ?>" class="gridflex-social-icon-search" aria-label="<?php esc_attr_e('Search Button','gridflex'); ?>"><i class="fas fa-search" aria-hidden="true" title="<?php esc_attr_e('Search','gridflex'); ?>"></i></a><?php } ?>
</div>

<?php }


/**
* Author bio box
*/

function gridflex_add_author_bio_box() {
    $content='';
    if (is_single()) {
        $content .= '
            <div class="gridflex-author-bio">
            <div class="gridflex-author-bio-inside">
            <div class="gridflex-author-bio-top">
            <span class="gridflex-author-bio-gravatar">
                '. get_avatar( get_the_author_meta('email') , 80 ) .'
            </span>
            <div class="gridflex-author-bio-text">
                <div class="gridflex-author-bio-name">'.esc_html__( 'Author: ', 'gridflex' ).'<span>'. get_the_author_link() .'</span></div><div class="gridflex-author-bio-text-description">'. wp_kses_post( get_the_author_meta('description',get_query_var('author') ) ) .'</div>
            </div>
            </div>
            </div>
            </div>
        ';
    }
    return apply_filters( 'gridflex_add_author_bio_box', $content );
}


/**
* Post meta functions
*/

if ( ! function_exists( 'gridflex_post_tags' ) ) :
/**
 * Prints HTML with meta information for the tags.
 */
function gridflex_post_tags() {
    if ( 'post' == get_post_type() ) {
        /* translators: used between list items, there is a space after the comma */
        $tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'gridflex' ) );
        if ( $tags_list ) {
            /* translators: 1: list of tags. */
            printf( '<span class="gridflex-tags-links"><i class="fas fa-tags" aria-hidden="true"></i> ' . esc_html__( 'Tagged %1$s', 'gridflex' ) . '</span>', $tags_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
        }
    }
}
endif;


if ( ! function_exists( 'gridflex_grid_cats' ) ) :
function gridflex_grid_cats() {
    if ( 'post' == get_post_type() ) {
        /* translators: used between list items, there is a space */
        $categories_list = get_the_category_list( esc_html__( '&nbsp;', 'gridflex' ) );
        if ( $categories_list ) {
            /* translators: 1: list of categories. */
            printf( '<div class="gridflex-grid-post-categories">' . __( '<span class="gridflex-sr-only">Posted in </span>%1$s', 'gridflex' ) . '</div>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
        }
    }
}
endif;


if ( ! function_exists( 'gridflex_grid_postmeta' ) ) :
function gridflex_grid_postmeta() { ?>
    <?php global $post; ?>
    <?php if ( gridflex_get_option('show_post_author_home') || !(gridflex_get_option('hide_posted_date_home')) || (!(gridflex_get_option('hide_comments_link_home')) && (! post_password_required() && ( comments_open() || get_comments_number() ))) ) { ?>
    <div class="gridflex-grid-post-footer gridflex-grid-post-block">
    <div class="gridflex-grid-post-footer-inside">
    <?php if ( gridflex_get_option('show_post_author_home') ) { ?><span class="gridflex-grid-post-author gridflex-grid-post-meta"><a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php echo esc_html( get_the_author() ); ?></a></span><?php } ?>
    <?php if ( !(gridflex_get_option('hide_posted_date_home')) ) { ?><span class="gridflex-grid-post-date gridflex-grid-post-meta"><?php echo esc_html( get_the_date() ); ?></span><?php } ?>
    <?php if ( !(gridflex_get_option('hide_comments_link_home')) && (! post_password_required() && ( comments_open() || get_comments_number() )) ) { ?><span class="gridflex-grid-post-comments gridflex-grid-post-meta"><?php comments_popup_link( sprintf( wp_kses( /* translators: %s: post title */ __( '0 Comment<span class="gridflex-sr-only"> on %s</span>', 'gridflex' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ) ); ?></span><?php } ?>
    </div>
    </div>
    <?php } ?>
<?php }
endif;


function gridflex_is_grid_postmeta_active() {
    global $post;
    $grid_postmeta_active = false;
    if ( gridflex_get_option('show_post_author_home') || !(gridflex_get_option('hide_posted_date_home')) || (!(gridflex_get_option('hide_comments_link_home')) && (! post_password_required() && ( comments_open() || get_comments_number() ))) ) {
        $grid_postmeta_active = true;
    }
    return apply_filters( 'gridflex_is_grid_postmeta_active', $grid_postmeta_active );
}


if ( ! function_exists( 'gridflex_nongrid_postmeta' ) ) :
function gridflex_nongrid_postmeta() { ?>
    <?php global $post; ?>
    <?php if ( gridflex_get_option('show_post_author_home') || !(gridflex_get_option('hide_posted_date_home')) || (!(gridflex_get_option('hide_comments_link_home')) && (! post_password_required() && ( comments_open() || get_comments_number() ))) || gridflex_get_option('show_post_categories_home') ) { ?>
    <div class="gridflex-entry-meta-single">
    <?php if ( gridflex_get_option('show_post_author_home') ) { ?><span class="gridflex-entry-meta-single-author"><i class="far fa-user-circle" aria-hidden="true"></i>&nbsp;<span class="author vcard" itemscope="itemscope" itemtype="http://schema.org/Person" itemprop="author"><a class="url fn n" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php echo esc_html( get_the_author() ); ?></a></span></span><?php } ?>
    <?php if ( !(gridflex_get_option('hide_posted_date_home')) ) { ?><span class="gridflex-entry-meta-single-date"><i class="far fa-clock" aria-hidden="true"></i>&nbsp;<?php echo esc_html( get_the_date() ); ?></span><?php } ?>
    <?php if ( !(gridflex_get_option('hide_comments_link_home')) ) { ?><?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) { ?>
    <span class="gridflex-entry-meta-single-comments"><i class="far fa-comments" aria-hidden="true"></i>&nbsp;<?php comments_popup_link( sprintf( wp_kses( /* translators: %s: post title */ __( 'Leave a Comment<span class="gridflex-sr-only"> on %s</span>', 'gridflex' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ) ); ?></span>
    <?php } ?><?php } ?>
    <?php if ( gridflex_get_option('show_post_categories_home') ) { ?><?php gridflex_single_cats(); ?><?php } ?>
    </div>
    <?php } ?>
<?php }
endif;


if ( ! function_exists( 'gridflex_single_cats' ) ) :
function gridflex_single_cats() {
    if ( 'post' == get_post_type() ) {
        /* translators: used between list items, there is a space */
        $categories_list = get_the_category_list( esc_html__( ', ', 'gridflex' ) );
        if ( $categories_list ) {
            /* translators: 1: list of categories. */
            printf( '<span class="gridflex-entry-meta-single-cats"><i class="far fa-folder-open" aria-hidden="true"></i>&nbsp;' . __( '<span class="gridflex-sr-only">Posted in </span>%1$s', 'gridflex' ) . '</span>', $categories_list ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
        }
    }
}
endif;


if ( ! function_exists( 'gridflex_single_postmeta' ) ) :
function gridflex_single_postmeta() { ?>
    <?php global $post; ?>
    <?php if ( !(gridflex_get_option('hide_post_author')) || !(gridflex_get_option('hide_posted_date')) || !(gridflex_get_option('hide_comments_link')) || !(gridflex_get_option('hide_post_categories')) || !(gridflex_get_option('hide_post_edit')) ) { ?>
    <div class="gridflex-entry-meta-single">
    <?php if ( !(gridflex_get_option('hide_post_author')) ) { ?><span class="gridflex-entry-meta-single-author"><i class="far fa-user-circle" aria-hidden="true"></i>&nbsp;<span class="author vcard" itemscope="itemscope" itemtype="http://schema.org/Person" itemprop="author"><a class="url fn n" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php echo esc_html( get_the_author() ); ?></a></span></span><?php } ?>
    <?php if ( !(gridflex_get_option('hide_posted_date')) ) { ?><span class="gridflex-entry-meta-single-date"><i class="far fa-clock" aria-hidden="true"></i>&nbsp;<?php echo esc_html( get_the_date() ); ?></span><?php } ?>
    <?php if ( !(gridflex_get_option('hide_comments_link')) ) { ?><?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) { ?>
    <span class="gridflex-entry-meta-single-comments"><i class="far fa-comments" aria-hidden="true"></i>&nbsp;<?php comments_popup_link( sprintf( wp_kses( /* translators: %s: post title */ __( 'Leave a Comment<span class="gridflex-sr-only"> on %s</span>', 'gridflex' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ) ); ?></span>
    <?php } ?><?php } ?>
    <?php if ( !(gridflex_get_option('hide_post_categories')) && has_category() ) { ?><?php gridflex_single_cats(); ?><?php } ?>
    <?php if ( !(gridflex_get_option('hide_post_edit')) ) { ?><?php edit_post_link( sprintf( wp_kses( /* translators: %s: Name of current post. Only visible to screen readers */ __( 'Edit<span class="gridflex-sr-only"> %s</span>', 'gridflex' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ), '<span class="edit-link">&nbsp;&nbsp;<i class="far fa-edit" aria-hidden="true"></i> ', '</span>' ); ?><?php } ?>
    </div>
    <?php } ?>
<?php }
endif;


if ( ! function_exists( 'gridflex_page_postmeta' ) ) :
function gridflex_page_postmeta() { ?>
    <?php global $post; ?>
    <?php if ( !(gridflex_get_option('hide_page_author')) || !(gridflex_get_option('hide_page_date')) || !(gridflex_get_option('hide_page_comments')) ) { ?>
    <?php if ( !((is_front_page()) && (gridflex_get_option('hide_static_page_meta'))) ) { ?>
    <div class="gridflex-entry-meta-single">
    <?php if ( !(gridflex_get_option('hide_page_author')) ) { ?><span class="gridflex-entry-meta-single-author"><i class="far fa-user-circle" aria-hidden="true"></i>&nbsp;<span class="author vcard" itemscope="itemscope" itemtype="http://schema.org/Person" itemprop="author"><a class="url fn n" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"><?php echo esc_html( get_the_author() ); ?></a></span></span><?php } ?>
    <?php if ( !(gridflex_get_option('hide_page_date')) ) { ?><span class="gridflex-entry-meta-single-date"><i class="far fa-clock" aria-hidden="true"></i>&nbsp;<?php echo esc_html( get_the_date() ); ?></span><?php } ?>
    <?php if ( !(gridflex_get_option('hide_page_comments')) ) { ?><?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) { ?>
    <span class="gridflex-entry-meta-single-comments"><i class="far fa-comments" aria-hidden="true"></i>&nbsp;<?php comments_popup_link( sprintf( wp_kses( /* translators: %s: post title */ __( 'Leave a Comment<span class="gridflex-sr-only"> on %s</span>', 'gridflex' ), array( 'span' => array( 'class' => array(), ), ) ), wp_kses_post( get_the_title() ) ) ); ?></span>
    <?php } ?><?php } ?>
    </div>
    <?php } ?>
    <?php } ?>
<?php }
endif;


/**
* Posts navigation functions
*/

if ( ! function_exists( 'gridflex_wp_pagenavi' ) ) :
function gridflex_wp_pagenavi() {
    ?>
    <nav class="navigation posts-navigation gridflex-clearfix" role="navigation">
        <?php wp_pagenavi(); ?>
    </nav><!-- .navigation -->
    <?php
}
endif;

if ( ! function_exists( 'gridflex_posts_navigation' ) ) :
function gridflex_posts_navigation() {
    if ( !(gridflex_get_option('hide_posts_navigation')) ) {
        if ( function_exists( 'wp_pagenavi' ) ) {
            gridflex_wp_pagenavi();
        } else {
            if ( gridflex_get_option('posts_navigation_type') === 'normalnavi' ) {
                the_posts_navigation(array('prev_text' => esc_html__( 'Older posts', 'gridflex' ), 'next_text' => esc_html__( 'Newer posts', 'gridflex' )));
            } else {
                the_posts_pagination(array('mid_size' => 2, 'prev_text' => esc_html__( '&larr; Newer posts', 'gridflex' ), 'next_text' => esc_html__( 'Older posts &rarr;', 'gridflex' )));
            }
        }
    }
}
endif;

if ( ! function_exists( 'gridflex_post_navigation' ) ) :
function gridflex_post_navigation() {
    global $post;
    if ( !(gridflex_get_option('hide_post_navigation')) ) {
            the_post_navigation(array('prev_text' => esc_html__( '%title &rarr;', 'gridflex' ), 'next_text' => esc_html__( '&larr; %title', 'gridflex' )));
    }
}
endif;


/**
* Menu Functions
*/

// Get our wp_nav_menu() fallback, wp_page_menu(), to show a "Home" link as the first item
function gridflex_page_menu_args( $args ) {
    $args['show_home'] = true;
    return $args;
}
add_filter( 'wp_page_menu_args', 'gridflex_page_menu_args' );

function gridflex_primary_menu_text() {
   $menu_text = esc_html__( 'Menu', 'gridflex' );
    if ( gridflex_get_option('primary_menu_text') ) {
        $menu_text = gridflex_get_option('primary_menu_text');
    }
   return apply_filters( 'gridflex_primary_menu_text', $menu_text );
}

function gridflex_secondary_menu_text() {
   $menu_text = esc_html__( 'Menu', 'gridflex' );
    if ( gridflex_get_option('secondary_menu_text') ) {
        $menu_text = gridflex_get_option('secondary_menu_text');
    }
   return apply_filters( 'gridflex_secondary_menu_text', $menu_text );
}

function gridflex_top_fallback_menu() {
   wp_page_menu( array(
        'sort_column'  => 'menu_order, post_title',
        'menu_id'      => 'gridflex-menu-secondary-navigation',
        'menu_class'   => 'gridflex-secondary-nav-menu gridflex-menu-secondary',
        'container'    => 'ul',
        'echo'         => true,
        'link_before'  => '',
        'link_after'   => '',
        'before'       => '',
        'after'        => '',
        'item_spacing' => 'discard',
        'walker'       => '',
    ) );
}

function gridflex_fallback_menu() {
   wp_page_menu( array(
        'sort_column'  => 'menu_order, post_title',
        'menu_id'      => 'gridflex-menu-primary-navigation',
        'menu_class'   => 'gridflex-primary-nav-menu gridflex-menu-primary',
        'container'    => 'ul',
        'echo'         => true,
        'link_before'  => '',
        'link_after'   => '',
        'before'       => '',
        'after'        => '',
        'item_spacing' => 'discard',
        'walker'       => '',
    ) );
}

function gridflex_secondary_menu_location() {
    $secondary_menu_location = 'before-header';
    if ( gridflex_get_option('secondary_menu_location') ) {
        $secondary_menu_location = gridflex_get_option('secondary_menu_location');
    }
    return apply_filters( 'gridflex_secondary_menu_location', $secondary_menu_location );
}

function gridflex_secondary_menu_area() {
if ( gridflex_is_secondary_menu_active() ) { ?>
<div class="gridflex-container gridflex-secondary-menu-container gridflex-clearfix">
<div class="gridflex-secondary-menu-container-inside gridflex-clearfix">
<nav class="gridflex-nav-secondary" id="gridflex-secondary-navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement" role="navigation" aria-label="<?php esc_attr_e( 'Secondary Menu', 'gridflex' ); ?>">
<div class="gridflex-outer-wrapper">

<button class="gridflex-secondary-responsive-menu-icon" aria-controls="gridflex-menu-secondary-navigation" aria-expanded="false"><?php echo esc_html( gridflex_secondary_menu_text() ); ?></button>
<?php wp_nav_menu( array( 'theme_location' => 'secondary', 'menu_id' => 'gridflex-menu-secondary-navigation', 'menu_class' => 'gridflex-secondary-nav-menu gridflex-menu-secondary', 'fallback_cb' => 'gridflex_top_fallback_menu', 'container' => '', ) ); ?>

<?php if ( 'secondary-menu' === gridflex_social_buttons_location() ) { ?>
    <?php if ( gridflex_is_social_buttons_active() ) { ?>
        <?php gridflex_header_social_buttons(); ?>
        <div id="gridflex-search-overlay-wrap" class="gridflex-search-overlay">
          <div class="gridflex-search-overlay-content">
            <?php get_search_form(); ?>
          </div>
          <button class="gridflex-search-closebtn" aria-label="<?php esc_attr_e( 'Close Search', 'gridflex' ); ?>" title="<?php esc_attr_e('Close Search','gridflex'); ?>">&#xD7;</button>
        </div>
    <?php } ?>
<?php } ?>

</div>
</nav>
</div>
</div>
<?php }
}


/**
* Header Functions
*/

/**
 * Add a pingback url auto-discovery header for single posts, pages, or attachments.
 */
function gridflex_pingback_header() {
    if ( is_singular() && pings_open() ) {
        echo '<link rel="pingback" href="', esc_url( get_bloginfo( 'pingback_url' ) ), '">';
    }
}
add_action( 'wp_head', 'gridflex_pingback_header' );

// Get custom-logo URL
function gridflex_custom_logo() {
    if ( ! has_custom_logo() ) {return;}
    $gridflex_custom_logo_id = get_theme_mod( 'custom_logo' );
    $gridflex_logo = wp_get_attachment_image_src( $gridflex_custom_logo_id , 'full' );
    $gridflex_logo_src = $gridflex_logo[0];
    return apply_filters( 'gridflex_custom_logo', $gridflex_logo_src );
}

// Site Title
function gridflex_site_title() {
    if ( is_front_page() && is_home() ) { ?>
            <h1 class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php } elseif ( is_home() ) { ?>
            <h1 class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php } elseif ( is_singular() ) { ?>
            <p class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php } elseif ( is_category() ) { ?>
            <p class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php } elseif ( is_tag() ) { ?>
            <p class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php } elseif ( is_author() ) { ?>
            <p class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php } elseif ( is_archive() && !is_category() && !is_tag() && !is_author() ) { ?>
            <p class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php } elseif ( is_search() ) { ?>
            <p class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php } elseif ( is_404() ) { ?>
            <p class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php } else { ?>
            <h1 class="gridflex-site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>
            <?php if ( !(gridflex_get_option('hide_tagline')) ) { ?><p class="gridflex-site-description"><?php bloginfo( 'description' ); ?></p><?php } ?>
    <?php }
}

function gridflex_header_image_destination() {
    $url = home_url( '/' );
    if ( gridflex_get_option('header_image_destination') ) {
        $url = gridflex_get_option('header_image_destination');
    }
    return apply_filters( 'gridflex_header_image_destination', $url );
}

function gridflex_header_image_markup() {
    if ( get_header_image() ) {
        if ( gridflex_get_option('remove_header_image_link') ) {
            the_header_image_tag( array( 'class' => 'gridflex-header-img', 'alt' => '' ) );
        } else { ?>
            <a href="<?php echo esc_url( gridflex_header_image_destination() ); ?>" rel="home" class="gridflex-header-img-link"><?php the_header_image_tag( array( 'class' => 'gridflex-header-img', 'alt' => '' ) ); ?></a>
        <?php }
    }
}

function gridflex_header_image_details() {
    global $post;

    $header_image_custom_title = '';
    if ( gridflex_get_option('header_image_custom_title') ) {
        $header_image_custom_title = gridflex_get_option('header_image_custom_title');
    }

    $header_image_custom_description = '';
    if ( gridflex_get_option('header_image_custom_description') ) {
        $header_image_custom_description = gridflex_get_option('header_image_custom_description');
    }

    if ( !(gridflex_get_option('hide_header_image_details')) ) {
        if ( !(gridflex_get_option('hide_header_image_title')) || !(gridflex_get_option('hide_header_image_description')) ) {
            if ( gridflex_get_option('header_image_custom_text') ) {
                if ( $header_image_custom_title || $header_image_custom_description ) { ?>
                    <div class="gridflex-header-image-info">
                    <div class="gridflex-header-image-info-inside">
                        <?php if ( !(gridflex_get_option('hide_header_image_title')) ) { ?><?php if ( $header_image_custom_title ) { ?><p class="gridflex-header-image-site-title gridflex-header-image-block"><?php echo wp_kses_post( force_balance_tags( do_shortcode($header_image_custom_title) ) ); ?></p><?php } ?><?php } ?>
                        <?php if ( !(gridflex_get_option('hide_header_image_description')) ) { ?><?php if ( $header_image_custom_description ) { ?><p class="gridflex-header-image-site-description gridflex-header-image-block"><?php echo wp_kses_post( force_balance_tags( do_shortcode($header_image_custom_description) ) ); ?></p><?php } ?><?php } ?>
                    </div>
                    </div>
                <?php }
            } else { ?>
                <div class="gridflex-header-image-info">
                <div class="gridflex-header-image-info-inside">
                    <?php if ( !(gridflex_get_option('hide_header_image_title')) ) { ?><p class="gridflex-header-image-site-title gridflex-header-image-block"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p><?php } ?>
                    <?php if ( !(gridflex_get_option('hide_header_image_description')) ) { ?><p class="gridflex-header-image-site-description gridflex-header-image-block"><?php bloginfo( 'description' ); ?></p><?php } ?>
                </div>
                </div>
            <?php }
        }
    }
}

function gridflex_header_image_wrapper() { ?>
    <div class="gridflex-header-image gridflex-clearfix">
    <?php gridflex_header_image_markup(); ?>
    <?php gridflex_header_image_details(); ?>
    </div>
    <?php
}

function gridflex_header_image() {
    if ( gridflex_get_option('hide_header_image') ) { return; }
    if ( get_header_image() ) {
        gridflex_header_image_wrapper();
    }
}


/**
* CSS Classes Functions
*/

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


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

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

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

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

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

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

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

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

    $classes[] = 'gridflex-float-grid';

    $classes[] = 'gridflex-centered-grid';

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

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

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

    $classes[] = 'gridflex-header-banner-active';

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

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

    if ( gridflex_is_primary_menu_active() ) {
        $classes[] = 'gridflex-primary-menu-active';
    }
    $classes[] = 'gridflex-primary-mobile-menu-active';
    if ( gridflex_get_option('center_primary_menu') ) {
        $classes[] = 'gridflex-primary-menu-centered';
    }

    if ( gridflex_is_secondary_menu_active() ) {
        $classes[] = 'gridflex-secondary-menu-active';
    }
    $classes[] = 'gridflex-secondary-mobile-menu-active';
    if ( gridflex_get_option('center_secondary_menu') ) {
        $classes[] = 'gridflex-secondary-menu-centered';
    }

    if ( 'primary-menu' === gridflex_social_buttons_location() ) {
        $classes[] = 'gridflex-primary-social-icons';
    } else {
        $classes[] = 'gridflex-secondary-social-icons';
    }

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

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

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


/**
* More Custom Functions
*/

// Change excerpt more word
function gridflex_excerpt_more($more) {
    if ( is_admin() ) {
        return $more;
    }
    return '...';
}
add_filter('excerpt_more', 'gridflex_excerpt_more');

if ( ! function_exists( 'wp_body_open' ) ) :
    /**
     * Fire the wp_body_open action.
     *
     * Added for backwards compatibility to support pre 5.2.0 WordPress versions.
     */
    function wp_body_open() { // phpcs:ignore WPThemeReview.CoreFunctionality.PrefixAllGlobals.NonPrefixedFunctionFound
        /**
         * Triggered after the opening <body> tag.
         */
        do_action( 'wp_body_open' ); // phpcs:ignore WPThemeReview.CoreFunctionality.PrefixAllGlobals.NonPrefixedHooknameFound
    }
endif;


/**
* Custom Hooks
*/

function gridflex_before_header() {
    do_action('gridflex_before_header');
}

function gridflex_after_header() {
    do_action('gridflex_after_header');
}

function gridflex_before_main_content() {
    do_action('gridflex_before_main_content');
}
add_action('gridflex_before_main_content', 'gridflex_top_widgets', 20 );

function gridflex_after_main_content() {
    do_action('gridflex_after_main_content');
}
add_action('gridflex_after_main_content', 'gridflex_bottom_widgets', 10 );

function gridflex_sidebar_one() {
    do_action('gridflex_sidebar_one');
}
add_action('gridflex_sidebar_one', 'gridflex_sidebar_one_widgets', 10 );

function gridflex_sidebar_two() {
    do_action('gridflex_sidebar_two');
}
add_action('gridflex_sidebar_two', 'gridflex_sidebar_two_widgets', 10 );

function gridflex_before_single_post() {
    do_action('gridflex_before_single_post');
}

function gridflex_before_single_post_title() {
    do_action('gridflex_before_single_post_title');
}

function gridflex_after_single_post_title() {
    do_action('gridflex_after_single_post_title');
}

function gridflex_top_single_post_content() {
    do_action('gridflex_top_single_post_content');
}

function gridflex_bottom_single_post_content() {
    do_action('gridflex_bottom_single_post_content');
}

function gridflex_after_single_post_content() {
    do_action('gridflex_after_single_post_content');
}

function gridflex_after_single_post() {
    do_action('gridflex_after_single_post');
}

function gridflex_before_single_page() {
    do_action('gridflex_before_single_page');
}

function gridflex_before_single_page_title() {
    do_action('gridflex_before_single_page_title');
}

function gridflex_after_single_page_title() {
    do_action('gridflex_after_single_page_title');
}

function gridflex_after_single_page_content() {
    do_action('gridflex_after_single_page_content');
}

function gridflex_after_single_page() {
    do_action('gridflex_after_single_page');
}

function gridflex_before_comments() {
    do_action('gridflex_before_comments');
}

function gridflex_after_comments() {
    do_action('gridflex_after_comments');
}

function gridflex_before_footer() {
    do_action('gridflex_before_footer');
}

function gridflex_after_footer() {
    do_action('gridflex_after_footer');
}

function gridflex_before_nongrid_post_title() {
    do_action('gridflex_before_nongrid_post_title');
}

function gridflex_after_nongrid_post_title() {
    do_action('gridflex_after_nongrid_post_title');
}

if ( 'before-header' === gridflex_secondary_menu_location() ) {
    add_action('gridflex_before_header', 'gridflex_secondary_menu_area', 50 );
} elseif ( 'after-header' === gridflex_secondary_menu_location() ) {
    add_action('gridflex_after_header', 'gridflex_secondary_menu_area', 50 );
} elseif ( 'before-footer' === gridflex_secondary_menu_location() ) {
    add_action('gridflex_before_footer', 'gridflex_secondary_menu_area', 50 );
} elseif ( 'after-footer' === gridflex_secondary_menu_location() ) {
    add_action('gridflex_after_footer', 'gridflex_secondary_menu_area', 50 );
} else {
    add_action('gridflex_before_header', 'gridflex_secondary_menu_area', 50 );
}

if ( ! function_exists( 'gridflex_remove_theme_support' ) ) :
function gridflex_remove_theme_support() {

    if ( gridflex_is_fitvids_active() ) {
        // Remove responsive embedded content support.
        remove_theme_support( 'responsive-embeds' );
    }

}
endif;
add_action( 'after_setup_theme', 'gridflex_remove_theme_support', 1000 );


/**
* Media functions
*/

function gridflex_media_content_grid() {
    global $post; ?>
    <?php if ( has_post_thumbnail($post->ID) ) { ?>
    <div class="gridflex-grid-post-thumbnail gridflex-grid-post-block">
        <a href="<?php echo esc_url( get_permalink() ); ?>" class="gridflex-grid-post-thumbnail-link" title="<?php /* translators: %s: post title. */ echo esc_attr( sprintf( __( 'Permanent Link to %s', 'gridflex' ), the_title_attribute( 'echo=0' ) ) ); ?>"><?php the_post_thumbnail('gridflex-360w-300h-image', array('class' => 'gridflex-grid-post-thumbnail-img', 'title' => the_title_attribute('echo=0'))); ?></a>

        <?php if ( !(gridflex_get_option('hide_post_title_home')) || gridflex_get_option('show_post_categories_home') || gridflex_is_grid_postmeta_active() ) { ?>
        <div class="gridflex-thumbnail-overlay gridflex-clearfix">
        <div class="gridflex-thumbnail-overlay-inside gridflex-clearfix">
        <div class="gridflex-grid-post-details gridflex-grid-post-block">
        <?php if ( gridflex_get_option('show_post_categories_home') && has_category() ) { gridflex_grid_cats(); } ?>

        <?php if ( !(gridflex_get_option('hide_post_title_home')) ) { ?><?php the_title( sprintf( '<h3 class="gridflex-grid-post-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' ); ?><?php } ?>

        <?php gridflex_grid_postmeta(); ?>
        </div>
        </div>
        </div>
        <?php } ?>
    </div>
    <?php } else { ?>
    <div class="gridflex-grid-post-thumbnail gridflex-grid-post-thumbnail-default gridflex-grid-post-block">
        <a href="<?php echo esc_url( get_permalink() ); ?>" class="gridflex-grid-post-thumbnail-link" title="<?php /* translators: %s: post title. */ echo esc_attr( sprintf( __( 'Permanent Link to %s', 'gridflex' ), the_title_attribute( 'echo=0' ) ) ); ?>"><img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/no-image-360-300.jpg' ); ?>" class="gridflex-grid-post-thumbnail-img"/></a>

        <?php if ( !(gridflex_get_option('hide_post_title_home')) || gridflex_get_option('show_post_categories_home') || gridflex_is_grid_postmeta_active() ) { ?>
        <div class="gridflex-thumbnail-overlay gridflex-clearfix">
        <div class="gridflex-thumbnail-overlay-inside gridflex-clearfix">
        <div class="gridflex-grid-post-details gridflex-grid-post-block">
        <?php if ( gridflex_get_option('show_post_categories_home') && has_category() ) { gridflex_grid_cats(); } ?>

        <?php if ( !(gridflex_get_option('hide_post_title_home')) ) { ?><?php the_title( sprintf( '<h3 class="gridflex-grid-post-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h3>' ); ?><?php } ?>

        <?php gridflex_grid_postmeta(); ?>
        </div>
        </div>
        </div>
        <?php } ?>
    </div>
    <?php } ?>
<?php }

function gridflex_media_content_single() {
    global $post;
    if ( has_post_thumbnail() ) {
        if ( !(gridflex_get_option('hide_thumbnail')) ) {
            if ( gridflex_get_option('thumbnail_link') == 'no' ) { ?>
                <div class="gridflex-post-thumbnail-single">
                <?php
                if ( is_page_template( array( 'template-full-width-post.php' ) ) ) {
                    the_post_thumbnail('gridflex-1422w-autoh-image', array('class' => 'gridflex-post-thumbnail-single-img', 'title' => the_title_attribute('echo=0')));
                } else {
                    the_post_thumbnail('gridflex-1074w-autoh-image', array('class' => 'gridflex-post-thumbnail-single-img', 'title' => the_title_attribute('echo=0')));
                }
                ?>
                </div>
            <?php } else { ?>
                <div class="gridflex-post-thumbnail-single">
                <?php if ( is_page_template( array( 'template-full-width-post.php' ) ) ) { ?>
                    <a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php /* translators: %s: post title. */ echo esc_attr( sprintf( __( 'Permanent Link to %s', 'gridflex' ), the_title_attribute( 'echo=0' ) ) ); ?>" class="gridflex-post-thumbnail-single-link"><?php the_post_thumbnail('gridflex-1422w-autoh-image', array('class' => 'gridflex-post-thumbnail-single-img', 'title' => the_title_attribute('echo=0'))); ?></a>
                <?php } else { ?>
                    <a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php /* translators: %s: post title. */ echo esc_attr( sprintf( __( 'Permanent Link to %s', 'gridflex' ), the_title_attribute( 'echo=0' ) ) ); ?>" class="gridflex-post-thumbnail-single-link"><?php the_post_thumbnail('gridflex-1074w-autoh-image', array('class' => 'gridflex-post-thumbnail-single-img', 'title' => the_title_attribute('echo=0'))); ?></a>
                <?php } ?>
                </div>
    <?php   }
        }
    }
}

function gridflex_media_content_single_location() {
    global $post;
    if( gridflex_get_option('featured_media_under_post_title') ) {
        add_action('gridflex_after_single_post_title', 'gridflex_media_content_single', 10 );
    } else {
        add_action('gridflex_before_single_post_title', 'gridflex_media_content_single', 10 );
    }
}
add_action('template_redirect', 'gridflex_media_content_single_location', 100 );

function gridflex_media_content_page() {
    global $post; ?>
    <?php
    if ( has_post_thumbnail() ) {
        if ( !(gridflex_get_option('hide_page_thumbnail')) ) {
            if ( gridflex_get_option('thumbnail_link_page') == 'no' ) { ?>
                <div class="gridflex-post-thumbnail-single">
                <?php
                if ( is_page_template( array( 'template-full-width-page.php' ) ) ) {
                    the_post_thumbnail('gridflex-1422w-autoh-image', array('class' => 'gridflex-post-thumbnail-single-img', 'title' => the_title_attribute('echo=0')));
                } else {
                    the_post_thumbnail('gridflex-1074w-autoh-image', array('class' => 'gridflex-post-thumbnail-single-img', 'title' => the_title_attribute('echo=0')));
                }
                ?>
                </div>
            <?php } else { ?>
                <div class="gridflex-post-thumbnail-single">
                <?php if ( is_page_template( array( 'template-full-width-page.php' ) ) ) { ?>
                    <a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php /* translators: %s: post title. */ echo esc_attr( sprintf( __( 'Permanent Link to %s', 'gridflex' ), the_title_attribute( 'echo=0' ) ) ); ?>" class="gridflex-post-thumbnail-single-link"><?php the_post_thumbnail('gridflex-1422w-autoh-image', array('class' => 'gridflex-post-thumbnail-single-img', 'title' => the_title_attribute('echo=0'))); ?></a>
                <?php } else { ?>
                    <a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php /* translators: %s: post title. */ echo esc_attr( sprintf( __( 'Permanent Link to %s', 'gridflex' ), the_title_attribute( 'echo=0' ) ) ); ?>" class="gridflex-post-thumbnail-single-link"><?php the_post_thumbnail('gridflex-1074w-autoh-image', array('class' => 'gridflex-post-thumbnail-single-img', 'title' => the_title_attribute('echo=0'))); ?></a>
                <?php } ?>
                </div>
    <?php   }
        }
    }
    ?>
<?php }

function gridflex_media_content_page_location() {
    global $post;
    if( gridflex_get_option('featured_media_under_page_title') ) {
        add_action('gridflex_after_single_page_title', 'gridflex_media_content_page', 10 );
    } else {
        add_action('gridflex_before_single_page_title', 'gridflex_media_content_page', 10 );
    }
}
add_action('template_redirect', 'gridflex_media_content_page_location', 110 );


/**
* Enqueue scripts and styles
*/

function gridflex_scripts() {
    wp_enqueue_style('gridflex-maincss', get_stylesheet_uri(), array(), null);
    wp_enqueue_style('fontawesome', get_template_directory_uri() . '/assets/css/all.min.css', array(), null );
    wp_enqueue_style('gridflex-webfont', '//fonts.googleapis.com/css?family=Domine:400,700|Oswald:400,700|Frank+Ruhl+Libre:400,700&amp;display=swap', array(), null);

    $gridflex_fitvids_active = false;
    if ( gridflex_is_fitvids_active() ) {
        $gridflex_fitvids_active = true;
    }
    if ( $gridflex_fitvids_active ) {
        wp_enqueue_script('fitvids', get_template_directory_uri() .'/assets/js/jquery.fitvids.min.js', array( 'jquery' ), null, true);
    }

    $gridflex_backtotop_active = false;
    if ( gridflex_is_backtotop_active() ) {
        $gridflex_backtotop_active = true;
    }

    $gridflex_primary_menu_active = false;
    if ( gridflex_is_primary_menu_active() ) {
        $gridflex_primary_menu_active = true;
    }
    $gridflex_secondary_menu_active = false;
    if ( gridflex_is_secondary_menu_active() ) {
        $gridflex_secondary_menu_active = true;
    }

    $gridflex_sticky_sidebar_active = true;
    if ( is_singular() ) {
        if ( is_page_template( array( 'template-full-width-page.php', 'template-full-width-post.php' ) ) ) {
           $gridflex_sticky_sidebar_active = false;
        }
    } else {
        $gridflex_sticky_sidebar_active = false;
    }
    if ( $gridflex_sticky_sidebar_active ) {
        wp_enqueue_script('ResizeSensor', get_template_directory_uri() .'/assets/js/ResizeSensor.min.js', array( 'jquery' ), null, true);
        wp_enqueue_script('theia-sticky-sidebar', get_template_directory_uri() .'/assets/js/theia-sticky-sidebar.min.js', array( 'jquery' ), null, true);
    }

    wp_enqueue_script('gridflex-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), null, true );
    wp_enqueue_script('gridflex-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), null, true );
    wp_enqueue_script('gridflex-customjs', get_template_directory_uri() .'/assets/js/custom.js', array( 'jquery', 'imagesloaded' ), null, true);

    wp_localize_script( 'gridflex-customjs', 'gridflex_ajax_object',
        array(
            'ajaxurl' => esc_url_raw( admin_url( 'admin-ajax.php' ) ),
            'primary_menu_active' => $gridflex_primary_menu_active,
            'secondary_menu_active' => $gridflex_secondary_menu_active,
            'sticky_sidebar_active' => $gridflex_sticky_sidebar_active,
            'fitvids_active' => $gridflex_fitvids_active,
            'backtotop_active' => $gridflex_backtotop_active,
        )
    );

    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }

    wp_enqueue_script('gridflex-html5shiv-js', get_template_directory_uri() .'/assets/js/html5shiv.js', array('jquery'), null, true);

    wp_localize_script('gridflex-html5shiv-js','gridflex_custom_script_vars',array(
        'elements_name' => esc_html__('abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video', 'gridflex'),
    ));
}
add_action( 'wp_enqueue_scripts', 'gridflex_scripts' );

/**
 * Enqueue IE compatible scripts and styles.
 */
function gridflex_ie_scripts() {
    wp_enqueue_script( 'respond', get_template_directory_uri(). '/assets/js/respond.min.js', array(), null, false );
    wp_script_add_data( 'respond', 'conditional', 'lt IE 9' );
}
add_action( 'wp_enqueue_scripts', 'gridflex_ie_scripts' );

/**
 * Enqueue styles for the block-based editor.
 */
function gridflex_block_editor_styles() {
    wp_enqueue_style( 'gridflex-block-editor-style', get_template_directory_uri() . '/assets/css/editor-blocks.css', array(), null );
}
add_action( 'enqueue_block_editor_assets', 'gridflex_block_editor_styles' );

/**
 * Enqueue customizer styles.
 */
function gridflex_enqueue_customizer_styles() {
    wp_enqueue_style( 'gridflex-customizer-styles', get_template_directory_uri() . '/assets/css/customizer-style.css', array(), null );
    wp_enqueue_style('fontawesome', get_template_directory_uri() . '/assets/css/all.min.css', array(), null );
}
add_action( 'customize_controls_enqueue_scripts', 'gridflex_enqueue_customizer_styles' );


/**
 * Register Custom Block Styles
 */

if ( function_exists( 'register_block_style' ) ) :
    function gridflex_register_block_styles() {

        /**
         * Register block style
         */
        register_block_style( 'core/button', array( 'name' => 'gridflex-button', 'label' => __( 'GridFlex Button', 'gridflex' ), 'is_default' => true, 'style_handle' => 'gridflex-maincss', ) ); // phpcs:ignore WPThemeReview.PluginTerritory.ForbiddenFunctions.editor_blocks_register_block_style

    }
    add_action( 'init', 'gridflex_register_block_styles' );
endif;


// Header styles
if ( ! function_exists( 'gridflex_header_style' ) ) :
function gridflex_header_style() {
    $header_text_color = get_header_textcolor();
    //if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) { return; }
    ?>
    <style type="text/css">
    <?php if ( ! display_header_text() ) : ?>
        .gridflex-site-title, .gridflex-site-description {position: absolute;clip: rect(1px, 1px, 1px, 1px);}
    <?php else : ?>
        .gridflex-site-title, .gridflex-site-title a, .gridflex-site-description {color: #<?php echo esc_attr( $header_text_color ); ?>;}
    <?php endif; ?>
    </style>
    <?php
}
endif;