?php
/**
* NexGi Demo Theme functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package NexGi_Demo_Theme
*/
if ( ! defined( '_S_VERSION' ) ) {
// Replace the version number of the theme on each release.
define( '_S_VERSION', '1.1.23' );
}
/**
* 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 nexgi_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on NexGi Demo Theme, use a find and replace
* to change 'nexgi' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'nexgi', 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
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 https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'menu-1' => esc_html__( 'Primary', 'nexgi' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
)
);
// Set up the WordPress core custom background feature.
add_theme_support(
'custom-background',
apply_filters(
'nexgi_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support(
'custom-logo',
array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
}
add_action( 'after_setup_theme', 'nexgi_setup' );
/**
* 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 nexgi_content_width() {
$GLOBALS['content_width'] = apply_filters( 'nexgi_content_width', 640 );
}
add_action( 'after_setup_theme', 'nexgi_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function nexgi_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'nexgi' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'nexgi' ),
'before_widget' => '',
'before_title' => '',
)
);
}
add_action( 'widgets_init', 'nexgi_widgets_init' );
/**
* Register widget area.
*/
function blog_sidebar_widget_init() {
register_sidebar(
array(
'name' => esc_html__( 'Blog Sidebar', 'nexgi' ),
'id' => 'blog-sidebar',
'description' => esc_html__( 'Add widgets here.', 'nexgi' ),
'before_widget' => '',
'before_title' => '',
)
);
}
add_action( 'widgets_init', 'blog_sidebar_widget_init' );
/**
* Enqueue scripts and styles.
*/
function nexgi_scripts() {
wp_enqueue_style( 'nexgi-slick-style', get_template_directory_uri() . '/assets/css/slick.css', array(), _S_VERSION );
wp_enqueue_style( 'nexgi-slick-theme', get_template_directory_uri() . '/assets/css/slick-theme.css', array(), _S_VERSION );
wp_enqueue_style( 'nexgi-aos', get_template_directory_uri() . '/assets/css/aos.css', array(), _S_VERSION );
wp_enqueue_style( 'nexgi-style', get_template_directory_uri() . '/assets/css/app.min.css', array(), _S_VERSION );
wp_enqueue_script('jquery');
wp_enqueue_script( 'nexgi-bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array(), _S_VERSION, true );
wp_enqueue_script( 'nexgi-lozad', get_template_directory_uri() . '/assets/js/lozad.js', array(), _S_VERSION, true );
wp_enqueue_script( 'nexgi-gsap', get_template_directory_uri() . '/assets/js/gsap/gsap.min.js', array(), _S_VERSION, true );
wp_enqueue_script( 'nexgi-slick', get_template_directory_uri() . '/assets/js/slick.min.js', array(), _S_VERSION, true );
wp_enqueue_script( 'nexgi-aosJS', get_template_directory_uri() . '/assets/js/aos.js', array(), _S_VERSION, true );
wp_enqueue_script( 'nexgi-ThreeJS', get_template_directory_uri() . '/assets/js/three.min.js', array(), _S_VERSION, true );
wp_enqueue_script( 'nexgi-TweenJS', get_template_directory_uri() . '/assets/js/TweenMax.min.js', array(), _S_VERSION, true );
wp_enqueue_script( 'nexgi-HoverJS', get_template_directory_uri() . '/assets/js/hover-effect.umd.js', array(), _S_VERSION, true );
wp_enqueue_script( 'nexgi-script', get_template_directory_uri() . '/assets/js/app.min.js', array(), _S_VERSION, true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'nexgi_scripts' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require get_template_directory() . '/inc/template-functions.php';
require get_template_directory() . '/inc/shortcode/nx_all_blog.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Jetpack compatibility file.
*/
if ( defined( 'JETPACK__VERSION' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}
require get_template_directory() . '/template-parts/blogs/header-blog-slider/vc-comp-post-slider.php';
/**
* Custom blocks additions.
*/
require get_template_directory() . '/blocks/blocks.php';
require get_template_directory() . '/vc_to_bootstrap/index.php';
// Allow SVG
add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
global $wp_version;
if ( $wp_version !== '4.7.1' ) {
return $data;
}
$filetype = wp_check_filetype( $filename, $mimes );
return [
'ext' => $filetype['ext'],
'type' => $filetype['type'],
'proper_filename' => $data['proper_filename']
];
}, 10, 4 );
function cc_mime_types( $mimes ){
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'cc_mime_types' );
function fix_svg() {
echo '';
}
add_action( 'admin_head', 'fix_svg' );
// Show Menus to header
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => __( 'super' ),
'extra-menu' => __( 'Extra Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
function aboutTheFounder() {
ob_start();
include('theme-sections/about-founder.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('aboutFounderInit', 'aboutTheFounder');
function servicesSlider() {
ob_start();
include('theme-sections/services-slider.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('servicesSliderInit', 'servicesSlider');
function awardsFlip() {
ob_start();
include('theme-sections/flipable-content.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('awardsFlipInit', 'awardsFlip');
function sproutsNumber() {
ob_start();
include('theme-sections/sprouts-num.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('sproutsNumberInit', 'sproutsNumber');
function ourTeamSec() {
ob_start();
include('theme-sections/our-team.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('ourTeamSecInit', 'ourTeamSec');
function ourTeamAll() {
ob_start();
include('theme-sections/our-team-all.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('ourTeamAllInit', 'ourTeamAll');
function growHome() {
ob_start();
include('theme-sections/grow.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('growInit', 'growHome');
function subscribePop() {
ob_start();
include('template-parts/views/popup-subscribe.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('subscribePopInit', 'subscribePop');
function careers_job_list($atts) {
$args = array(
'post_type' => 'job',
'posts_per_page' => 5,
);
$query = new WP_Query($args);
$output = ''; // Initialize the output variable to an empty string
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
// Capture the job card HTML for each job post in a temporary variable
ob_start();
include 'template-parts/jobs/job-card.php';
$job_card = ob_get_clean();
// Replace placeholders in the job card with dynamic data
$job_card = str_replace('{job_link}', get_permalink(), $job_card);
$job_card = str_replace('{job_title}', get_the_title(), $job_card);
// Append the job card to the output
$output .= $job_card;
}
wp_reset_postdata();
} else {
$output = 'No jobs found.';
}
return $output;
}
add_shortcode('job_listInit', 'careers_job_list');
function display_job_categories() {
$categories = get_terms(array(
'taxonomy' => 'job-categories',
'hide_empty' => false, // Set to true to hide empty categories
));
if (!empty($categories)) {
$output = '';
} else {
$output = 'No job categories found.';
}
return $output;
}
add_shortcode('job_categories', 'display_job_categories');
function careerJobs() {
ob_start();
include('template-parts/jobs/jobs.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('careerJobsInit', 'careerJobs');
require get_template_directory() . '/inc/flipable-cards/flipable-card-map.php';
require get_template_directory() . '/inc/scrollable-content-map/scrollable-content-map.php';
require get_template_directory() . '/inc/swappable-images/swappable-images.php';
require get_template_directory() . '/inc/video-tag/video-tag-map.php';
function serviceCat() {
ob_start();
include('theme-sections/services-categories.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('serviceCatInit', 'serviceCat');
function scrollableContent() {
ob_start();
include('theme-sections/scollable-content.php');
$output = ob_get_clean();
return $output;
}
add_shortcode('scrollableContentInit', 'scrollableContent');
add_action('send_headers', function () {
// Referrer Policy
header('Referrer-Policy: strict-origin-when-cross-origin');
// Content Security Policy (CSP) - WARNING: ye bahut permissive h, tighten karna better h
header("Content-Security-Policy: default-src *; script-src * 'unsafe-inline' 'unsafe-eval'; style-src * 'unsafe-inline' 'unsafe-eval'; img-src * data:; connect-src *; font-src * data:; frame-src *;");
// Strict Transport Security
header('Strict-Transport-Security: max-age=31536000; includeSubDomains; preload');
// Clickjacking protection
header('X-Frame-Options: SAMEORIGIN');
// MIME sniffing protection
header('X-Content-Type-Options: nosniff');
// Debug header (optional)
header('X-Debug-SecurityHeaders: active');
// Permissions-Policy
header("Permissions-Policy: camera=(), microphone=(), geolocation=(), interest-cohort=()");
});