HEX
Server: LiteSpeed
System: Linux spg20.cloudpowerdns.com 5.14.0-611.35.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 25 03:46:09 EST 2026 x86_64
User: carrerup (3153)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/carrerup/.trash/techland/functions.php
<?php

/**
 *
 * @package WordPress
 * @subpackage techland
 * @since techland 1.0
 *
**/


/*************************************************
## GOOGLE FONTS
*************************************************/

if (! function_exists('techland_fonts_url')) {
    function techland_fonts_url()
    {
        $fonts_url = '';

        $nunito = _x('on', 'Roboto font: on or off', 'techland');
        $quicksand = _x('on', 'Pacifico font: on or off', 'techland');
		$caveat = _x('on', 'Caveat font: on or off', 'techland');

        if ('off' !== $nunito or 'off' !== $quicksand  or 'off' !== $caveat) {
            $font_families = array();

            if ('off' !== $nunito) {
                $font_families[] = 'Nunito Sans:400,400i,700,700i,800,800i,900,900i';
            }

            if ('off' !== $quicksand) {
                $font_families[] = 'Quicksand:300,400,700';
            }

            if ('off' !== $caveat) {
                $font_families[] = 'Caveat:400,700';
            }

            $query_args = array(
                'family' => urlencode(implode('|', $font_families)),
                'subset' => urlencode('latin,latin-ext'),
            );

            $fonts_url = add_query_arg($query_args, "//fonts.googleapis.com/css");
        }

        return $fonts_url;
    }
}

/*************************************************
## STYLES AND SCRIPTS
*************************************************/

function techland_theme_scripts()
{
    $rtl = is_rtl() ? '-rtl' : '';
    // ## CSS

    // Bootstrap framework
    wp_enqueue_style('bootstrap', get_template_directory_uri() . '/css/bootstrap'.$rtl.'.min.css', false, '1.0');

    // font families
    wp_register_style('ionicon', get_template_directory_uri() . '/css/ionicon-stylesheet.css', false, '1.0');
    wp_register_style('flaticon', get_template_directory_uri() . '/css/flaticon.css', false, '1.0');
    wp_enqueue_style('font-awesome', get_template_directory_uri() . '/css/fontawesome.min.css', false, '1.0');
    wp_register_style('owl-carousel', get_template_directory_uri() . '/css/owl.carousel.min.css', false, '1.0');

    // theme inner pages files
    wp_enqueue_style('nice-select', get_template_directory_uri() . '/css/nice-select.css', false, '1.0');
    wp_enqueue_style('techland-general-style', get_template_directory_uri() . '/css/framework-style'.$rtl.'.css', false, '1.0');

    // plugins
    wp_enqueue_style('aos', get_template_directory_uri() . '/libs/aos/aos.css', false, '1.0');
    wp_enqueue_style('jquery-fancybox', get_template_directory_uri() . '/libs/fancybox/jquery.fancybox.min.css', false, '1.0');
    wp_enqueue_style('jarallax', get_template_directory_uri() . '/libs/jarallax/jarallax.css', false, '1.0');
    wp_enqueue_style('slick', get_template_directory_uri() . '/libs/slick/slick.css', false, '1.0');

    // critical styles
    wp_enqueue_style('techland-critical', get_template_directory_uri() . '/css/critical'.$rtl.'.css', false, '1.0');

    if ( is_page() && '1' != techland_settings( 'force_main_color' ) ) {

        $techland_page_clr = techland_mbsettings( 'techland_page_color_style', '1' );
        if ( $techland_page_clr != 'default' && $techland_page_clr != 'custom' && $techland_page_clr != false ) {
            wp_enqueue_style('techland-color', get_template_directory_uri() . '/css/color-'.$techland_page_clr.'.css', false, '1.0');
        }

    } else {

        $techland_clr = techland_settings( 'theme_color', '1' );
        if ( $techland_clr != 'custom' && $techland_clr != 'default' ) {
            wp_enqueue_style('techland-color', get_template_directory_uri() . '/css/color-'.techland_settings( 'theme_color', '1' ).'.css', false, '1.0');
        }
    }

    // techland-main-style
    wp_enqueue_style('techland-style', get_template_directory_uri() . '/css/style'.$rtl.'.css', false, '1.0');
    // techland-update-style
    wp_enqueue_style('techland-update', get_template_directory_uri() . '/css/update'.$rtl.'.css', false, '1.0');

    // upload Google Webfonts
    wp_enqueue_style('techland-fonts', techland_fonts_url(), array(), '1.0');


    // ## JS
    // theme inner page files
    wp_enqueue_script('device', get_template_directory_uri() . '/js/device.min.js', array('jquery'), '1.0', false);
    wp_enqueue_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('techland-settings', get_template_directory_uri() . '/js/framework-settings.js', array('jquery'), '1.0', true);
    wp_enqueue_script('jquery-nice-select', get_template_directory_uri() . '/js/jquery.nice-select.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('smooth-scroll-polyfills', get_template_directory_uri() . '/js/smooth-scroll.polyfills.min.js', array('jquery'), '1.0', true);
    wp_register_script('owl-carousel', get_template_directory_uri() . '/js/owl.carousel.min.js', array('jquery'), '1.0', true);
    wp_register_script('jquery-scrollup', get_template_directory_uri() . '/js/jquery.scrollUp.min.js', array('jquery'), '1.0', true);

    // plugins
    wp_enqueue_script('aos', get_template_directory_uri() . '/libs/aos/aos.js', array('jquery'), '1.0', true);
    wp_enqueue_script('jquery-countto', get_template_directory_uri() . '/libs/countTo/jquery.countTo.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('jquery-fancybox', get_template_directory_uri() . '/libs/fancybox/jquery.fancybox.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('isotope-pkgd', get_template_directory_uri() . '/libs/isotope/isotope.pkgd.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('jarallax', get_template_directory_uri() . '/libs/jarallax/jarallax.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('slick', get_template_directory_uri() . '/libs/slick/slick.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('vanilla-tilt-babel', get_template_directory_uri() . '/libs/vanilla-tilt/vanilla-tilt.babel.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('tweenmax', get_template_directory_uri() . '/libs/TweenMax/TweenMax.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('vivus', get_template_directory_uri() . '/libs/vivus/vivus.min.js', array('jquery'), '1.0', true);
    wp_register_script('wavify', get_template_directory_uri() . '/libs/wavify/wavify.min.js', array('jquery'), '1.0', true);
    wp_enqueue_script('techland-main', get_template_directory_uri() . '/js/main.js', array('jquery'), '1.0', true);

    if ( 'masonry' == techland_settings( 'index_type', 'default' ) ) {
        wp_enqueue_script('masonry');
    }

    // browser hacks
    wp_enqueue_script('modernizr', get_template_directory_uri() . '/js/modernizr.min.js', array('jquery'), '1,0', false);
    wp_script_add_data('modernizr', 'conditional', 'lt IE 9');
    wp_enqueue_script('respond', get_template_directory_uri() . '/js/respond.min.js', array('jquery'), '1.0', false);
    wp_script_add_data('respond', 'conditional', 'lt IE 9');
    wp_enqueue_script('html5shiv', get_template_directory_uri() . '/js/html5shiv.min.js', array('jquery'), '1.0', false);
    wp_script_add_data('html5shiv', 'conditional', 'lt IE 9');

    // comment form reply
    if ( is_singular() ) {
        wp_enqueue_script('comment-reply');
    }
}
add_action('wp_enqueue_scripts', 'techland_theme_scripts');

if ( is_admin() ) {
    add_action( 'wp_default_scripts','techland_wp_default_custom_script');
    function techland_wp_default_custom_script( $scripts ){
        $scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker.js", array('iris'), false,1);
        did_action('init') && $scripts->localize(
            'wp-color-picker',
            'wpColorPickerL10n',
            array(
                'clear'=> esc_html__('Clear','techland'),
                'clearAriaLabel'=> esc_html__('Clear color','techland'),
                'defaultString'=> esc_html__('Default','techland' ),
                'defaultAriaLabel'=> esc_html__('Select default color','techland' ),
                'pick'=> esc_html__( 'Select Color','techland'),
                'defaultLabel'=> esc_html__( 'Color value','techland'),
            )
        );
    }
}

/*************************************************
## ADMIN STYLE AND SCRIPTS
*************************************************/


function techland_admin_scripts()
{

    // Update CSS within in Admin
    wp_enqueue_script('techland-custom-admin', get_template_directory_uri() . '/js/framework-admin.js');
}
add_action('admin_enqueue_scripts', 'techland_admin_scripts');


/*************************************************
## THEME OPTION & METABOXES & SHORTCODES
*************************************************/

// Check Visual Composer Activation
if (function_exists('vc_set_as_theme')) {
    vc_set_as_theme($disable_updater = false);
    vc_is_updater_disabled();
}

// Check Metabox Plugin Activation
if (! function_exists('rwmb_meta')) {
    function rwmb_meta($key, $args = '', $post_id = null)
    {
        return false;
    }
}

// Theme post and page meta plugin for customization and more features
include get_template_directory() . '/inc/metaboxes.php';

require_once get_parent_theme_file_path( '/inc/merlin/admin-menu.php' );
// Template-functions
include get_template_directory() . '/inc/template-functions.php';

// Theme parts
include get_template_directory() . '/inc/template-parts/menu.php';
include get_template_directory() . '/inc/template-parts/post-formats.php';
include get_template_directory() . '/inc/template-parts/paginations.php';
include get_template_directory() . '/inc/template-parts/comment-parts.php';
include get_template_directory() . '/inc/template-parts/small-parts.php';
include get_template_directory() . '/inc/template-parts/header-parts.php';
include get_template_directory() . '/inc/template-parts/footer-parts.php';
include get_template_directory() . '/inc/template-parts/page-hero.php';
include get_template_directory() . '/inc/template-parts/breadcrumbs.php';

// Theme dynamic css setting file
include get_template_directory() . '/inc/custom-style.php';

// TGM plugin activation
include get_template_directory() . '/inc/class-tgm-plugin-activation.php';

// Redux theme options panel
include get_template_directory() . '/inc/theme-options/options.php';

// WooCommerce init
if (class_exists('woocommerce')) {
    include get_template_directory() . '/woocommerce/init.php';
}

/*************************************************
## THEME SETUP
*************************************************/


if (! isset($content_width)) {
    $content_width = 960;
}

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

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

    // theme supports
    add_theme_support('title-tag');
    add_theme_support('custom-background');
    add_theme_support('custom-header');
    add_theme_support('html5', array( 'search-form' ));

    //WooCommerce
    if ( class_exists( 'woocommerce' ) ) {
  		add_theme_support( 'woocommerce' );
  	}

    // Make theme available for translation
    // Translations can be filed in the /languages/ directory
    load_theme_textdomain('techland', get_template_directory() . '/languages');

    register_nav_menus(array(
        'header_menu_1' => esc_html__('Header Menu 1', 'techland'),
        'footer_menu_1' => esc_html__('Footer Widget Area Menu', 'techland'),
    ));
}
add_action('after_setup_theme', 'techland_theme_setup');


/*************************************************
## WIDGET COLUMNS
*************************************************/


function techland_widgets_init()
{
    register_sidebar(array(
        'name' => esc_html__('Blog Sidebar', 'techland'),
        'id' => 'sidebar-1',
        'description' => esc_html__('These widgets for the Blog page.', 'techland'),
        'before_widget' => '<div class="nt-sidebar-inner-widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="nt-sidebar-inner-widget-title widget-title">',
        'after_title' => '</h4>'
    ));
    register_sidebar(array(
        'name' => esc_html__('Blog Single Sidebar', 'techland'),
        'id' => 'techland-single-sidebar',
        'description' => esc_html__('These widgets for the Blog single page.', 'techland'),
        'before_widget' => '<div class="nt-sidebar-inner-widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="nt-sidebar-inner-widget-title widget-title">',
        'after_title' => '</h4>'
    ));
    register_sidebar(array(
        'name' => esc_html__('Sidebar Menu', 'techland'),
        'id' => 'side-menu',
        'description' => esc_html__('These widgets for the side menu.', 'techland'),
        'before_widget' => '<div class="side-menu__menu %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="nt-side-menu-widget-title">',
        'after_title' => '</h4>'
    ));
    register_sidebar(array(
        'name' => esc_html__('Header Languages Menu', 'techland'),
        'id' => 'header-languages',
        'description' => esc_html__('These widgets for the header languages menu.', 'techland'),
        'before_widget' => '<div class="top-bar__choose-lang js-choose-lang">',
        'after_widget' => '</div>',
        'before_title' => '<span class="hidden">',
        'after_title' => '</span>'
    ));

    // custom register footer widgets from theme optipons panel
    if ( ! empty( techland_settings('custom_widgets') ) ) {
        $sidebars = techland_settings('custom_widgets');
        foreach ( $sidebars as $id => $column ) {
            register_sidebar(array(
                'name' => sprintf(esc_html__('Custom Footer Widget %s', 'techland'), $id+1),
                'description' => sprintf(esc_html__('This widget has %s column.', 'techland'), $column),
                'id' => 'custom-footer-widget-'.($id + 1),
                'before_widget' => '<div class="nt-sidebar-footer-widget %2$s"><div class="footer__item">',
                'after_widget' => '</div></div>',
                'before_title' => '<h4 class="nt-sidebar-footer-widget-title">',
                'after_title' => '</h4>'
            ));
        }
    }
}
add_action('widgets_init', 'techland_widgets_init');


/*************************************************
## INCLUDE THE TGM_PLUGIN_ACTIVATION CLASS.
*************************************************/


function techland_register_required_plugins()
{
    $plugins = array(

        array(
            'name' => esc_html__('Contact Form 7', "techland"),
            'slug' => 'contact-form-7',
        ),
        array(
            'name' => esc_html__('Meta Box', "techland"),
            'slug' => 'meta-box',
            'required' => true,
        ),
        array(
            'name' => esc_html__('Theme Options Panel', "techland"),
            'slug' => 'redux-framework',
            'required' => true,
        ),
        array(
            'name' => esc_html__('Safe SVG', "techland"),
            'slug' => 'safe-svg',
            'required' => true,
        ),
        array(
            'name' => esc_html__('Custom Post Type UI', "techland"),
            'slug' => 'custom-post-type-ui',
            'required' => false,
        ),
        array(
            'name' => esc_html__('The Grid', "techland"),
            'slug' => 'the-grid',
            'source' => 'https://ninetheme.com/documentation/plugins/the-grid.zip',
            'required' => false,
        ),
        array(
            'name' => esc_html__('Social Icons Widget by WPZOOM', "techland"),
            'slug' => 'social-icons-widget-by-wpzoom',
            'required' => false,
        ),
        array(
            'name' => esc_html__('WooCommerce', "techland"),
            'slug' => 'woocommerce',
            'required' => false,
        ),
        array(
            'name' => esc_html__('Metabox Tabs', "techland"),
            'slug' => 'meta-box-tabs',
            'source' => 'https://ninetheme.com/documentation/plugins/meta-box-tabs.zip',
            'required' => true,
            'version' => '1.1.5',
        ),
        array(
            'name' => esc_html__('Metabox Show/Hide', "techland"),
            'slug' => 'meta-box-show-hide',
            'source' => 'https://ninetheme.com/documentation/plugins/meta-box-show-hide.zip',
            'required' => true,
            'version' => '1.3',
        ),
        array(
            'name' => esc_html__('Envato Auto Update Theme', "techland"),
            'slug' => 'envato-market',
            'source' => 'https://ninetheme.com/documentation/plugins/envato-market.zip',
            'required' => false,
            'version' => '2.0.3',
        ),
        array(
            'name' => esc_html__('Page Builder', "techland"),
            'slug' => 'js_composer',
            'source' => 'https://ninetheme.com/documentation/plugins/js_composer.zip',
            'required' => true,
        ),
        array(
            'name' => esc_html__('Revolution Slider', "techland"),
            'slug' => 'revolution_slider',
            'source' => 'https://ninetheme.com/documentation/plugins/revolution_slider.zip',
            'required' => false,
        ),
        array(
            'name' => esc_html__('WP Techland Shortcodes', "techland"),
            'slug' => 'techland-shortcodes',
            'source' => get_template_directory() . '/plugins/techland-shortcodes.zip',
            'required' => true,
            'version' => '1.6.9',
        )
    );

    $config = array(
        'id' => 'tgmpa',
        'default_path' => '',
        'menu' => 'tgmpa-install-plugins',
        'parent_slug' => apply_filters( 'ninetheme_parent_slug', 'themes.php' ),
        'has_notices' => true,
        'dismissable' => true,
        'dismiss_msg' => '',
        'is_automatic' => true,
        'message' => '',
    );
    tgmpa($plugins, $config);
}
add_action('tgmpa_register', 'techland_register_required_plugins');


/*************************************************
## THEME SETUP WIZARD
    https://github.com/richtabor/MerlinWP
*************************************************/

require_once get_parent_theme_file_path( '/inc/merlin/class-merlin.php' );
require_once get_parent_theme_file_path( '/inc/demo-wizard-config.php' );

function techland_merlin_local_import_files() {
    return array(
        array(
            'import_file_name' => esc_html__('Demo Import', "techland"),
            // xml data
            'local_import_file' => get_parent_theme_file_path( 'inc/merlin/demodata/data.xml' ),
            // widget data
            'local_import_widget_file' => get_parent_theme_file_path( 'inc/merlin/demodata/widgets.wie' ),
            // option tree -> theme options
            'local_import_redux' => array(
                array(
                    'file_path' => trailingslashit( get_template_directory() ). 'inc/merlin/demodata/redux.json',
                    'option_name' => 'techland'
                )
            )
        )
    );
}
add_filter( 'merlin_import_files', 'techland_merlin_local_import_files' );


/**
 * Execute custom code after the whole import has finished.
 */
function architect_merlin_after_import_setup() {
    // Assign menus to their locations.
    $primary = get_term_by( 'name', 'Menu 1', 'nav_menu' );

    set_theme_mod(
        'nav_menu_locations', array(
            'header_menu_1' => $primary->term_id
        )
    );

    // Assign front page and posts page (blog page).
    $front_page_id = get_page_by_title( 'Home' );
    $blog_page_id  = get_page_by_title( 'Blog' );

    update_option( 'show_on_front', 'page' );
    update_option( 'page_on_front', $front_page_id->ID );
    update_option( 'page_for_posts', $blog_page_id->ID );

    $cartPage = get_option('woocommerce_cart_page_id');
    $cart_page_data = array(
        'ID' => $cartPage,
        'post_content' => '[woocommerce_cart]'
    );
    wp_update_post( $cart_page_data );

    $checkoutPage = get_option('woocommerce_checkout_page_id');
    $checkout_page_data = array(
        'ID' => $checkoutPage,
        'post_content' => '[woocommerce_checkout]'
    );
    wp_update_post( $checkout_page_data );
    
    // removes block widgets from sidebars after demodata install
    if ( is_active_sidebar( 'sidebar-1' ) ) {
        $sidebars_widgets = get_option( 'sidebars_widgets' );
        $sidebar_1_array  = $sidebars_widgets['sidebar-1'];
        foreach( $sidebar_1_array as $k => $v ) {
            if( substr( $v, 0, strlen("block-") ) === "block-" ) {
                unset($sidebars_widgets['sidebar-1'][$k]);
            }
        }
        update_option( 'sidebars_widgets', $sidebars_widgets);
    }
}
add_action( 'merlin_after_all_import', 'architect_merlin_after_import_setup' );

add_action('init', 'do_output_buffer'); function do_output_buffer() { ob_start(); }

add_filter( 'woocommerce_prevent_automatic_wizard_redirect', '__return_true' );