HEX
Server: Apache
System: Linux 65-254-81-60.cprapid.com 4.18.0-477.27.2.el8_8.x86_64 #1 SMP Fri Sep 29 08:21:01 EDT 2023 x86_64
User: roshanchandy (1003)
PHP: 8.4.12
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/roshanchandy/public_html/petiva/wp-content/themes/petiva/inc/template-helper.php
<?php

/**
 * Custom template tags for this theme
 *
 * Eventually, some of the functionality here could be replaced by core features.
 *
 * @package petiva
 */


/**Header Selection from Page or Customize Option**/
function petiva_check_header()
{
    $petiva_header_style = function_exists('get_field') ? get_field('header_style') : NULL;
    $petiva_default_header_style = get_theme_mod('choose_default_header', 'header-style-1');

    if ($petiva_header_style == 'header-style-1' && empty($_GET['s'])) {
        get_template_part('template-parts/header/header-1');
    } elseif ($petiva_header_style == 'header-style-2' && empty($_GET['s'])) {
        get_template_part('template-parts/header/header-2');
    } elseif ($petiva_header_style == 'header-style-3' && empty($_GET['s'])) {
        get_template_part('template-parts/header/header-3');
    } else {

        /** default header style **/
        if ($petiva_default_header_style == 'header-style-2') {
            get_template_part('template-parts/header/header-2');
        } elseif ($petiva_default_header_style == 'header-style-3') {
            get_template_part('template-parts/header/header-3');
        } else {
            get_template_part('template-parts/header/header-1');
        }
    }
}
add_action('petiva_header_style', 'petiva_check_header', 10);




/**header logo**/
function petiva_header_logo()
{
    $petiva_logo_on = function_exists('get_field') ? get_field('is_enable_sec_logo') : NULL;
    $petiva_site_logo = get_theme_mod('logo', get_template_directory_uri() . '/assets/images/logo.png');
    $petiva_secondary_logo = get_theme_mod('seconday_logo', get_template_directory_uri() . '/assets/images/logo.png');

    if (!empty($petiva_logo_on) && !empty($petiva_site_logo)) {
        // Display secondary logo
        echo '<a class="secondary-logo" href="' . esc_url(home_url('/')) . '">
                <img src="' . esc_url($petiva_secondary_logo) . '" alt="' . esc_attr__('logo', 'petiva') . '" />
              </a>';
        return true;
    } elseif (!empty($petiva_site_logo)) {
        // Display primary logo
        echo '<a class="standard-logo" href="' . esc_url(home_url('/')) . '">
                <img src="' . esc_url($petiva_site_logo) . '" alt="' . esc_attr__('logo', 'petiva') . '" />
              </a>';
        return true;
    }

    return false; // No logo was displayed
}



/**Rigister Nav Menu**/
function petiva_header_menu()
{
?>
    <?php
    wp_nav_menu([
        'theme_location' => 'main-menu',
        'menu_class'     => 'navbar-nav mb-lg-0',
        'container'      => '',
        'fallback_cb'    => 'Petpath_Walker_Nav_Menu::fallback',
        'walker'         => new \TPCore\Widgets\Petpath_Walker_Nav_Menu,
    ]);
    ?>
    <?php
}




/**Footer Copyright Text**/
function petiva_copyright_text()
{
    $home_url = esc_url(home_url('/')); // Get the home URL
    $copyright_text = get_theme_mod('petiva_copyright', 'Copyright © 2025 <span class="currentYear"></span>  <a href="' . $home_url . '">petiva</a> - All Rights Reserved');
    echo wp_kses($copyright_text, array(
        'a' => array(
            'href' => array(),
        ),
    ));
}



/**WPML Menu Language Select Option**/
function petiva_header_lang_defualt()
{
    $petiva_header_lang = get_theme_mod('petiva_header_lang', false);
    if ($petiva_header_lang) : ?>

        <ul>
            <li><a href="javascript:void(0)" class="lang__btn"><?php print esc_html__('English', 'petiva'); ?> <i class="fa-light fa-angle-down"></i></a>
                <?php do_action('petiva_language'); ?>
            </li>
        </ul>

    <?php endif; ?>
<?php
}



/**WPML Menu Language Select Option**/
function _petiva_language($mar)
{
    return $mar;
}
function petiva_language_list()
{

    $mar = '';
    $languages = apply_filters('wpml_active_languages', NULL, 'orderby=id&order=desc');
    if (!empty($languages)) {
        $mar = '<ul>';
        foreach ($languages as $lan) {
            $active = $lan['active'] == 1 ? 'active' : '';
            $mar .= '<li class="' . $active . '"><a href="' . $lan['url'] . '">' . $lan['translated_name'] . '</a></li>';
        }
        $mar .= '</ul>';
    } else {
        //remove this code when send themeforest reviewer team
        $mar .= '<ul>';
        $mar .= '<li><a href="#">' . esc_html__('English', 'petiva') . '</a></li>';
        $mar .= '<li><a href="#">' . esc_html__('Bangla', 'petiva') . '</a></li>';
        $mar .= '<li><a href="#">' . esc_html__('French', 'petiva') . '</a></li>';
        $mar .= ' </ul>';
    }
    print _petiva_language($mar);
}
add_action('petiva_language', 'petiva_language_list');




// theme color

function petiva_custom_color()
{

    // Secondary Color
    $color_codep = get_theme_mod('petiva_pri_color', '#FB7B53');
    $custom_cssp = '';
    if ($color_codep != '') {
        $custom_cssp .= ":root{
            --p1: $color_codep !important;
        }";
    }
    // Secondary Color
    $color_code2 = get_theme_mod('petiva_secondary_color', '#FFD15C');
    $custom_css2 = '';
    if ($color_code2 != '') {
        $custom_css2 .= ":root{
            --s2-color: $color_code2 !important;
        }";
    }
    // heding Color
    $color_code3 = get_theme_mod('petiva_heading_color', '#150B33');
    $custom_css3 = '';
    if ($color_code3 != '') {
        $custom_css3 .= ":root{
            --heading-color: $color_code3 !important;
        }";
    }
    //  Secondary Text Color
    $color_code4 = get_theme_mod('petiva_text_color', '#4F4C57');
    $custom_css4 = '';
    if ($color_code4 != '') {
        $custom_css4 .= ":root{
            --text-color: $color_code4 !important;
        }";
    }
    // Enqueue and add inline styles for Primary Color
    wp_register_style('petiva-custom3', false);
    wp_enqueue_style('petiva-custom3', false);
    wp_add_inline_style('petiva-custom3', $custom_cssp, true);
    // Enqueue and add inline styles for Secondary Color
    wp_register_style('petiva-custom-2', false);
    wp_enqueue_style('petiva-custom-2', false);
    wp_add_inline_style('petiva-custom-2', $custom_css2, true);
    // Enqueue and add inline styles for Secondary Color
    wp_register_style('petiva-custom-3', false);
    wp_enqueue_style('petiva-custom-3', false);
    wp_add_inline_style('petiva-custom-3', $custom_css3, true);
    // Enqueue and add inline styles for Secondary Color
    wp_register_style('petiva-custom-4', false);
    wp_enqueue_style('petiva-custom-4', false);
    wp_add_inline_style('petiva-custom-4', $custom_css4, true);
}
add_action('wp_enqueue_scripts', 'petiva_custom_color');