File: /home/mbkashyap/public_html/wp-content/plugins/astrology-booking/astrology-booking.php
<?php
/*
Plugin Name: Astrology Booking
Description: A WordPress plugin for astrology appointment booking with Razorpay payment integration.
Version: 1.0.0
Author: Your Name
License: GPL-2.0+
*/
// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}
// Define plugin constants
define('ASTRO_BOOKING_PATH', plugin_dir_path(__FILE__));
define('ASTRO_BOOKING_URL', plugin_dir_url(__FILE__));
// Include functions
require_once ASTRO_BOOKING_PATH . 'functions.php';
// Activation hook to create database tables
register_activation_hook(__FILE__, 'astro_booking_activate');
function astro_booking_activate() {
    global $wpdb;
    $charset_collate = $wpdb->get_charset_collate();
    
    // Create appointments table
    $table_name = $wpdb->prefix . 'astro_appointments';
    $sql = "CREATE TABLE $table_name (
        id bigint(20) NOT NULL AUTO_INCREMENT,
        client_name varchar(255) NOT NULL,
        client_email varchar(255) NOT NULL,
        appointment_date date NOT NULL,
        appointment_time time NOT NULL,
        price decimal(10,2) NOT NULL,
        payment_id varchar(255) DEFAULT NULL,
        status varchar(50) DEFAULT 'pending',
        created_at datetime DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (id)
    ) $charset_collate;";
    
    // Create availability table
    $avail_table = $wpdb->prefix . 'astro_availability';
    $avail_sql = "CREATE TABLE $avail_table (
        id bigint(20) NOT NULL AUTO_INCREMENT,
        avail_date date NOT NULL,
        start_time time NOT NULL,
        end_time time NOT NULL,
        price decimal(10,2) NOT NULL,
        PRIMARY KEY (id)
    ) $charset_collate;";
    
    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    dbDelta($sql);
    dbDelta($avail_sql);
    
    // Set default price
    update_option('astro_booking_default_price', 1000.00);
}
// Enqueue scripts and styles
add_action('wp_enqueue_scripts', 'astro_booking_enqueue_scripts');
function astro_booking_enqueue_scripts() {
    wp_enqueue_style('fullcalendar', ASTRO_BOOKING_URL . 'assets/lib/fullcalendar/fullcalendar.min.css');
    wp_enqueue_style('astro-booking', ASTRO_BOOKING_URL . 'assets/css/style.css');
    wp_enqueue_script('fullcalendar', ASTRO_BOOKING_URL . 'assets/lib/fullcalendar/fullcalendar.min.js', ['jquery'], null, true);
    wp_enqueue_script('astro-booking', ASTRO_BOOKING_URL . 'assets/js/frontend.js', ['jquery', 'fullcalendar'], null, true);
    wp_localize_script('astro-booking', 'astroBooking', [
        'ajax_url' => admin_url('admin-ajax.php'),
        'razorpay_key' => get_option('astro_booking_razorpay_key'),
    ]);
}
// Admin menu
add_action('admin_menu', 'astro_booking_admin_menu');
function astro_booking_admin_menu() {
    add_menu_page(
        'Astrology Booking',
        'Astrology Booking',
        'manage_options',
        'astro-booking',
        'astro_booking_admin_page',
        'dashicons-calendar-alt'
    );
    add_submenu_page(
        'astro-booking',
        'Availability',
        'Availability',
        'manage_options',
        'astro-availability',
        'astro_booking_availability_page'
    );
    add_submenu_page(
        'astro-booking',
        'Settings',
        'Settings',
        'manage_options',
        'astro-settings',
        'astro_booking_settings_page'
    );
}
// Shortcode for frontend booking
add_shortcode('astro_booking', 'astro_booking_shortcode');
function astro_booking_shortcode() {
    ob_start();
    include ASTRO_BOOKING_PATH . 'templates/frontend-booking.php';
    return ob_get_clean();
}
?>