/*
Theme Name: Softgen
Theme URI: https://wp.dynamiclayers.net/softgen
Author: DynamicLayers
Author URI: https://themeforest.net/user/dynamiclayers
Description: Softgen is a Software and Technology WordPress theme. Specially designed for Software Agency and IT Solution provider representing a software company with innovative technologies.
Version: 1.0.4
Requires at least: 5.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Text Domain: softgen
Tags: custom-background, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready

<?php
// Enable Gzip Compression
if (!ob_start("ob_gzhandler")) ob_start();

// Set Cache Control Headers
header("Cache-Control: public, max-age=31536000");

// Enable Browser Caching
function enable_browser_caching() {
    $expires = 60 * 60 * 24 * 30; // 30 days
    header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expires) . " GMT");
    header("Cache-Control: max-age=$expires, public");
}
enable_browser_caching();

// Remove Query Strings from Static Resources
function remove_query_strings($src) {
    return preg_replace('/\?.*/', '', $src);
}
add_filter('script_loader_src', 'remove_query_strings', 15, 1);
add_filter('style_loader_src', 'remove_query_strings', 15, 1);

// Optimize Heartbeat API (reduces unnecessary admin requests)
add_action('init', function () {
    global $pagenow;
    if ($pagenow !== 'post.php' && $pagenow !== 'post-new.php') {
        wp_deregister_script('heartbeat');
    }
});

// Disable WP Emoji Scripts
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');

// Optimize Database Queries
function optimize_database() {
    global $wpdb;
    $wpdb->query('OPTIMIZE TABLE ' . $wpdb->prefix . 'posts');
    $wpdb->query('OPTIMIZE TABLE ' . $wpdb->prefix . 'postmeta');
    $wpdb->query('OPTIMIZE TABLE ' . $wpdb->prefix . 'comments');
    $wpdb->query('OPTIMIZE TABLE ' . $wpdb->prefix . 'commentmeta');
}
add_action('wp_scheduled_event', 'optimize_database');

// End Output Buffering
ob_end_flush();
?>
*/