<?php
/**
 * Plugin Name: Restaurant Order System
 * Plugin URI:  https://vlabtech.com
 * Description: Complete restaurant ordering system with customer frontend, kitchen display, and admin management.
 * Version:     2.0.0
 * Author:      VLabTech
 * Author URI:  https://vlabtech.com
 * Text Domain: ros
 */

if ( ! defined( 'ABSPATH' ) ) exit;

define( 'ROS_VERSION', '2.0.0' );
define( 'ROS_PATH', plugin_dir_path( __FILE__ ) );
define( 'ROS_URL', plugin_dir_url( __FILE__ ) );

require_once ROS_PATH . 'includes/class-ros-db.php';
require_once ROS_PATH . 'includes/class-ros-ajax.php';
require_once ROS_PATH . 'includes/class-ros-shortcodes.php';
require_once ROS_PATH . 'admin/class-ros-admin.php';

register_activation_hook( __FILE__, array( 'ROS_DB', 'install' ) );

add_action( 'plugins_loaded', 'ros_init' );
function ros_init() {
    new ROS_Ajax();
    new ROS_Shortcodes();
    if ( is_admin() ) {
        new ROS_Admin();
    }
}

// Remove WP admin bar on ROS pages (it shifts layout)
add_action( 'after_setup_theme', function() {
    if ( ! is_admin() ) {
        // We'll check in template_redirect after shortcode detection
        add_action( 'template_redirect', function() {
            global $post;
            if ( ! $post ) return;
            $content = $post->post_content;
            if ( has_shortcode( $content, 'restaurant_customer' ) || has_shortcode( $content, 'restaurant_kitchen' ) ) {
                add_filter( 'show_admin_bar', '__return_false' );
            }
        }, 5 );
    }
} );
