80, 'width' => 250, 'flex-height' => true, 'flex-width' => true, ) ); // Add support for custom colors add_theme_support( 'editor-color-palette', array( array( 'name' => __( 'Primary Blue', 'bm-transport' ), 'slug' => 'primary-blue', 'color' => '#1e40af', ), array( 'name' => __( 'Secondary Orange', 'bm-transport' ), 'slug' => 'secondary-orange', 'color' => '#f97316', ), array( 'name' => __( 'Dark Gray', 'bm-transport' ), 'slug' => 'dark-gray', 'color' => '#0f172a', ), array( 'name' => __( 'Light Gray', 'bm-transport' ), 'slug' => 'light-gray', 'color' => '#f3f4f6', ), array( 'name' => __( 'Success Green', 'bm-transport' ), 'slug' => 'success-green', 'color' => '#10b981', ), ) ); // Add support for wide align add_theme_support( 'align-wide' ); // Add support for responsive embeds add_theme_support( 'responsive-embeds' ); // Register navigation menus register_nav_menus( array( 'primary' => __( 'Primary Menu', 'bm-transport' ), 'secondary' => __( 'Secondary Menu', 'bm-transport' ), 'footer' => __( 'Footer Menu', 'bm-transport' ), ) ); // Add custom image sizes for logistics/transport add_image_size( 'hero-image', 1920, 600, true ); add_image_size( 'service-card', 400, 300, true ); add_image_size( 'testimonial-avatar', 80, 80, true ); add_image_size( 'blog-featured', 800, 500, true ); } add_action( 'after_setup_theme', 'bm_transport_setup' ); // ============================================ // ENQUEUE STYLESHEETS & SCRIPTS // ============================================ /** * Enqueue theme stylesheets and scripts */ function bm_transport_enqueue_assets() { // Get theme version for cache busting $theme_version = wp_get_theme()->get( 'Version' ); // Enqueue main stylesheet wp_enqueue_style( 'bm-transport-main', get_stylesheet_uri(), array(), $theme_version, 'all' ); // Enqueue Google Fonts - Inter & Fira Code wp_enqueue_style( 'bm-transport-fonts', 'https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;700&family=Inter:wght@300;400;500;600;700;800&display=swap', array(), null, 'all' ); // Enqueue Font Awesome icons wp_enqueue_style( 'font-awesome', 'https://cdnjs.cloudflare. com/ajax/libs/font-awesome/6.4.0/css/all.min.css', array(), '6.4.0', 'all' ); // Enqueue main JavaScript file wp_enqueue_script( 'bm-transport-main', get_template_directory_uri() . '/assets/js/main.js', array(), $theme_version, true ); // Enqueue jQuery if needed for backward compatibility wp_enqueue_script( 'jquery' ); // Pass data to JavaScript wp_localize_script( 'bm-transport-main', 'bmTransport', array( 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'siteUrl' => site_url(), 'themePath' => get_template_directory_uri(), ) ); } add_action( 'wp_enqueue_scripts', 'bm_transport_enqueue_assets' ); // ============================================ // ADMIN ENQUEUE STYLES // ============================================ /** * Enqueue admin stylesheet for better editor experience */ function bm_transport_enqueue_admin_assets() { wp_enqueue_style( 'bm-transport-admin', get_template_directory_uri() . '/assets/css/admin.css', array(), wp_get_theme()->get( 'Version' ), 'all' ); } add_action( 'admin_enqueue_scripts', 'bm_transport_enqueue_admin_assets' ); // ============================================ // WIDGET AREAS / SIDEBARS // ============================================ /** * Register widget areas */ function bm_transport_widgets_init() { // Primary Sidebar register_sidebar( array( 'name' => __( 'Primary Sidebar', 'bm-transport' ), 'id' => 'primary-sidebar', 'description' => __( 'Main sidebar for blog posts and pages', 'bm-transport' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); // Footer Widgets - 4 Columns for ( $i = 1; $i <= 4; $i++ ) { register_sidebar( array( 'name' => sprintf( __( 'Footer Widget %d', 'bm-transport' ), $i ), 'id' => 'footer-widget-' . $i, 'description' => sprintf( __( 'Footer widget area %d', 'bm-transport' ), $i ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } // Service Areas (Homepage) register_sidebar( array( 'name' => __( 'Service Highlights', 'bm-transport' ), 'id' => 'service-highlights', 'description' => __( 'Widget area for service highlights on homepage', 'bm-transport' ), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action( 'widgets_init', 'bm_transport_widgets_init' ); // ============================================ // CUSTOM POST TYPES // ============================================ /** * Register custom post type for Services */ function bm_transport_register_service_cpt() { $labels = array( 'name' => __( 'Services', 'bm-transport' ), 'singular_name' => __( 'Service', 'bm-transport' ), 'menu_name' => __( 'Services', 'bm-transport' ), 'name_admin_bar' => __( 'Service', 'bm-transport' ), 'add_new' => __( 'Add New', 'bm-transport' ), 'add_new_item' => __( 'Add New Service', 'bm-transport' ), 'new_item' => __( 'New Service', 'bm-transport' ), 'edit_item' => __( 'Edit Service', 'bm-transport' ), 'view_item' => __( 'View Service', 'bm-transport' ), 'all_items' => __( 'All Services', 'bm-transport' ), 'search_items' => __( 'Search Services', 'bm-transport' ), 'not_found' => __( 'No services found', 'bm-transport' ), ); $args = array( 'labels' => $labels, 'description' => __( 'Transport and logistics services', 'bm-transport' ), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'service' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 20, 'menu_icon' => 'dashicons-truck', 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'custom-fields' ), 'show_in_rest' => true, ); register_post_type( 'bm_service', $args ); } add_action( 'init', 'bm_transport_register_service_cpt' ); /** * Register custom post type for Testimonials */ function bm_transport_register_testimonial_cpt() { $labels = array( 'name' => __( 'Testimonials', 'bm-transport' ), 'singular_name' => __( 'Testimonial', 'bm-transport' ), 'menu_name' => __( 'Testimonials', 'bm-transport' ), 'add_new' => __( 'Add New', 'bm-transport' ), 'add_new_item' => __( 'Add New Testimonial', 'bm-transport' ), 'edit_item' => __( 'Edit Testimonial', 'bm-transport' ), 'view_item' => __( 'View Testimonial', 'bm-transport' ), ); $args = array( 'labels' => $labels, 'description' => __( 'Client testimonials and reviews', 'bm-transport' ), 'public' => true, 'publicly_queryable' => false, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => false, 'capability_type' => 'post', 'has_archive' => false, 'hierarchical' => false, 'menu_position' => 21, 'menu_icon' => 'dashicons-format-quote', 'supports' => array( 'title', 'editor', 'thumbnail' ), 'show_in_rest' => true, ); register_post_type( 'bm_testimonial', $args ); } add_action( 'init', 'bm_transport_register_testimonial_cpt' ); // ============================================ // CUSTOM TAXONOMIES // ============================================ /** * Register custom taxonomy for Services */ function bm_transport_register_service_taxonomy() { $labels = array( 'name' => __( 'Service Categories', 'bm-transport' ), 'singular_name' => __( 'Service Category', 'bm-transport' ), 'menu_name' => __( 'Categories', 'bm-transport' ), 'search_items' => __( 'Search Categories', 'bm-transport' ), 'all_items' => __( 'All Categories', 'bm-transport' ), 'edit_item' => __( 'Edit Category', 'bm-transport' ), 'add_new_item' => __( 'Add New Category', 'bm-transport' ), ); $args = array( 'labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'service-category' ), 'show_in_rest' => true, ); register_taxonomy( 'bm_service_category', array( 'bm_service' ), $args ); } add_action( 'init', 'bm_transport_register_service_taxonomy' ); // ============================================ // HELPER FUNCTIONS // ============================================ /** * Get theme option */ function bm_transport_get_option( $option_name, $default = '' ) { return get_theme_mod( 'bm_transport_' . $option_name, $default ); } /** * Get theme setting */ function bm_transport_get_setting( $setting_name, $default = '' ) { $settings = get_option( 'bm_transport_settings', array() ); return isset( $settings[ $setting_name ] ) ? $settings[ $setting_name ] : $default; } /** * Get formatted phone number */ function bm_transport_get_phone() { return bm_transport_get_setting( 'phone', '9712627517' ); } /** * Get formatted email */ function bm_transport_get_email() { return bm_transport_get_setting( 'email', 'support@bmtransport.in' ); } /** * Get formatted address */ function bm_transport_get_address() { return bm_transport_get_setting( 'address', 'FIRST FLOOR SHOP NO 04, PARMESHWAR ARCADE, HALVAD, Gujarat - 363330' ); } /** * Get custom logo */ function bm_transport_get_logo() { $custom_logo_id = get_theme_mod( 'custom_logo' ); return $custom_logo_id ? wp_get_attachment_image_src( $custom_logo_id, 'full' ) : false; } /** * Display custom logo */ function bm_transport_the_logo() { $logo = bm_transport_get_logo(); if ( $logo ) { echo ''; } else { echo '' . esc_html( get_bloginfo( 'name' ) ) . ''; } } /** * Get excerpt with custom length */ function bm_transport_get_excerpt( $post_id, $length = 20 ) { $post = get_post( $post_id ); $excerpt = $post->post_excerpt ? $post->post_excerpt : wp_trim_words( $post->post_content, $length ); return apply_filters( 'the_excerpt', $excerpt ); } /** * Truncate text */ function bm_transport_truncate_text( $text, $limit = 100 ) { if ( strlen( $text ) > $limit ) { return substr( $text, 0, $limit ) . '...'; } return $text; } /** * Check if page is home */ function bm_transport_is_home() { return is_front_page() || is_home(); } /** * Get theme color */ function bm_transport_get_color( $color_name = 'primary' ) { $colors = array( 'primary' => '#1e40af', 'secondary' => '#f97316', 'success' => '#10b981', 'danger' => '#ef4444', 'warning' => '#f59e0b', 'dark' => '#0f172a', ); return isset( $colors[ $color_name ] ) ? $colors[ $color_name ] : '#1e40af'; } // ============================================ // CONTENT FILTERING & MODIFICATION // ============================================ /** * Add custom classes to body tag */ function bm_transport_body_classes( $classes ) { // Add page type classes if ( is_single() ) { $classes[] = 'single-post'; $classes[] = 'single-' . get_post_type(); } if ( is_page() ) { $classes[] = 'page-' . get_the_ID(); } if ( is_archive() ) { $classes[] = 'archive-page'; } if ( is_search() ) { $classes[] = 'search-page'; } // Add device classes if ( wp_is_mobile() ) { $classes[] = 'is-mobile'; } return $classes; } add_filter( 'body_class', 'bm_transport_body_classes' ); /** * Remove unnecessary WordPress classes from posts */ function bm_transport_post_class( $classes ) { // Remove 'format-standard' class if present $classes = array_diff( $classes, array( 'format-standard' ) ); return $classes; } add_filter( 'post_class', 'bm_transport_post_class' ); /** * Modify excerpt length */ function bm_transport_excerpt_length( $length ) { return 25; // Number of words } add_filter( 'excerpt_length', 'bm_transport_excerpt_length' ); /** * Modify excerpt more text */ function bm_transport_excerpt_more( $more ) { return '... Read More'; } add_filter( 'excerpt_more', 'bm_transport_excerpt_more' ); // ============================================ // SECURITY & PERFORMANCE // ============================================ /** * Remove unnecessary WP version info */ function bm_transport_remove_version() { return ''; } add_filter( 'the_generator', 'bm_transport_remove_version' ); /** * Disable XML-RPC */ add_filter( 'xmlrpc_enabled', '__return_false' ); /** * Lazy load images */ function bm_transport_add_image_loading_attr( $html, $post_id ) { return str_replace( ' __( 'Security check failed', 'bm-transport' ) ) ); } // Get form data $name = sanitize_text_field( $_POST['name'] ?? '' ); $email = sanitize_email( $_POST['email'] ?? '' ); $phone = sanitize_text_field( $_POST['phone'] ?? '' ); $service = sanitize_text_field( $_POST['service'] ?? '' ); $message = sanitize_textarea_field( $_POST['message'] ?? '' ); // Validate required fields if ( empty( $name ) || empty( $email ) || empty( $message ) ) { wp_send_json_error( array( 'message' => __( 'Please fill all required fields', 'bm-transport' ) ) ); } // Send email $to = bm_transport_get_email(); $subject = sprintf( __( 'New Contact Form Submission from %s', 'bm-transport' ), $name ); $body = sprintf( __( "Name: %s\nEmail: %s\nPhone: %s\nService: %s\n\nMessage:\n%s", 'bm-transport' ), $name, $email, $phone, $service, $message ); $headers = array( 'Content-Type: text/plain; charset=UTF-8' ); $headers[] = 'From: ' . $email; $sent = wp_mail( $to, $subject, $body, $headers ); if ( $sent ) { wp_send_json_success( array( 'message' => __( 'Message sent successfully! ', 'bm-transport' ) ) ); } else { wp_send_json_error( array( 'message' => __( 'Failed to send message. Please try again.', 'bm-transport' ) ) ); } } add_action( 'wp_ajax_bm_transport_contact_form', 'bm_transport_handle_contact_form' ); add_action( 'wp_ajax_nopriv_bm_transport_contact_form', 'bm_transport_handle_contact_form' ); // ============================================ // INITIALIZATION HOOKS // ============================================ /** * Initialize theme on admin_init */ function bm_transport_admin_init() { // Register settings register_setting( 'bm_transport', 'bm_transport_settings' ); } add_action( 'admin_init', 'bm_transport_admin_init' ); /** * Add theme customizer options */ function bm_transport_customize_register( $wp_customize ) { // Add Section for Contact Information $wp_customize->add_section( 'bm_transport_contact', array( 'title' => __( 'Contact Information', 'bm-transport' ), 'priority' => 30, ) ); // Phone Setting $wp_customize->add_setting( 'bm_transport_phone', array( 'default' => '9712627517', 'sanitize_callback' => 'sanitize_text_field', ) ); $wp_customize->add_control( 'bm_transport_phone', array( 'label' => __( 'Phone Number', 'bm-transport' ), 'section' => 'bm_transport_contact', 'type' => 'text', ) ); // Email Setting $wp_customize->add_setting( 'bm_transport_email', array( 'default' => 'support@bmtransport.in', 'sanitize_callback' => 'sanitize_email', ) ); $wp_customize->add_control( 'bm_transport_email', array( 'label' => __( 'Email Address', 'bm-transport' ), 'section' => 'bm_transport_contact', 'type' => 'email', ) ); // Address Setting $wp_customize->add_setting( 'bm_transport_address', array( 'default' => 'FIRST FLOOR SHOP NO 04, PARMESHWAR ARCADE, HALVAD, Gujarat - 363330', 'sanitize_callback' => 'sanitize_textarea_field', ) ); $wp_customize->add_control( 'bm_transport_address', array( 'label' => __( 'Business Address', 'bm-transport' ), 'section' => 'bm_transport_contact', 'type' => 'textarea', ) ); } add_action( 'customize_register', 'bm_transport_customize_register' ); /** * End of functions. php * * @package BM_Transport */ ?> https://bmtransport.in/wp-sitemap-posts-post-1.xmlhttps://bmtransport.in/wp-sitemap-posts-page-1.xmlhttps://bmtransport.in/wp-sitemap-taxonomies-category-1.xmlhttps://bmtransport.in/wp-sitemap-users-1.xml