// ============================================================================= // DISABLE GENERATEPRESS CSS (We use Tailwind via WindPress instead) // ============================================================================= add_action('wp_enqueue_scripts', function() { wp_dequeue_style('generate-style'); wp_deregister_style('generate-style'); wp_dequeue_style('generate-dynamic'); wp_deregister_style('generate-dynamic'); }, 100); add_action('init', function() { add_filter('generate_dynamic_css_output', '__return_empty_string'); add_filter('generate_using_dynamic_css_external_file', '__return_false'); }); // ============================================================================= // ENQUEUE STYLES AND SCRIPTS // ============================================================================= add_action('wp_enqueue_scripts', function() { // Custom scripts (scripts.js in child theme root) wp_enqueue_script('theme-scripts', get_stylesheet_directory_uri() . '/scripts.js', array(), '1.0.0', true); }, 20); // ============================================================================= // ENQUEUE CHILD THEME STYLE.CSS (for brand colors, loads after Tailwind) // ============================================================================= add_action('wp_enqueue_scripts', function() { wp_enqueue_style( 'generatepress-child-style', get_stylesheet_directory_uri() . '/style.css', array(), '1.0.0' ); }, 999); // PERFORMANCE: Add defer attribute to theme scripts add_filter('script_loader_tag', function($tag, $handle) { $defer_scripts = array('theme-scripts'); if (in_array($handle, $defer_scripts)) { return str_replace(' src', ' defer src', $tag); } return $tag; }, 10, 2); // ============================================================================= // REGISTER CUSTOM POST TYPES // ============================================================================= add_action('init', function() { // HVAC Installation Cities register_post_type('hvac_install', array( 'labels' => array( 'name' => 'HVAC Installation', 'singular_name' => 'HVAC Installation City', 'menu_name' => 'HVAC Installation', 'add_new' => 'Add New City', 'add_new_item' => 'Add New HVAC Installation City', 'edit_item' => 'Edit City', 'new_item' => 'New City', 'view_item' => 'View City Page', 'search_items' => 'Search Cities', 'not_found' => 'No cities found', ), 'public' => true, 'has_archive' => false, 'rewrite' => array('slug' => 'hvac-installation'), 'menu_icon' => 'dashicons-admin-home', 'supports' => array('title'), 'show_in_rest' => true, )); // AC Repair Cities (template coming in next batch) register_post_type('ac_repair', array( 'labels' => array( 'name' => 'AC Repair', 'singular_name' => 'AC Repair City', 'menu_name' => 'AC Repair', 'add_new' => 'Add New City', 'add_new_item' => 'Add New AC Repair City', 'edit_item' => 'Edit City', 'new_item' => 'New City', 'view_item' => 'View City Page', 'search_items' => 'Search Cities', 'not_found' => 'No cities found', ), 'public' => true, 'has_archive' => false, 'rewrite' => array('slug' => 'ac-repair'), 'menu_icon' => 'dashicons-thermometer', 'supports' => array('title'), 'show_in_rest' => true, )); // Heating Repair Cities (template coming in next batch) register_post_type('heating_repair', array( 'labels' => array( 'name' => 'Heating Repair', 'singular_name' => 'Heating Repair City', 'menu_name' => 'Heating Repair', 'add_new' => 'Add New City', 'add_new_item' => 'Add New Heating Repair City', 'edit_item' => 'Edit City', 'new_item' => 'New City', 'view_item' => 'View City Page', 'search_items' => 'Search Cities', 'not_found' => 'No cities found', ), 'public' => true, 'has_archive' => false, 'rewrite' => array('slug' => 'heating-repair'), 'menu_icon' => 'dashicons-admin-generic', 'supports' => array('title'), 'show_in_rest' => true, )); }); // ============================================================================= // FLUSH REWRITE RULES ON THEME ACTIVATION // ============================================================================= add_action('after_switch_theme', function() { flush_rewrite_rules(); });