# Bidda School Management WordPress Integration Guide

## Overview

This guide explains how to deploy your Bidda school management system within WordPress by creating a custom WordPress plugin.

## Prerequisites

1. WordPress 5.0 or higher installed
2. FTP or file manager access to your WordPress installation
3. Basic understanding of WordPress plugin development

## Installation Steps

### 1. Prepare Your Files

1. Create a new folder named `bidda-school-management` in your WordPress plugins directory:
   ```
   /wp-content/plugins/bidda-school-management/
   ```

2. Copy all the plugin files into this directory:
   - `bidda-school-management.php` (main plugin file)
   - `includes/class-bidda-loader.php`
   - `includes/class-bidda-admin.php`
   - `includes/class-bidda-public.php`
   - `includes/bidda-wordpress-integration.php`
   - Any other files you've created

### 2. Activate the Plugin

1. Log in to your WordPress admin dashboard
2. Navigate to Plugins → Installed Plugins
3. Find "Bidda School Management" in the list
4. Click "Activate"

### 3. Configure the Plugin

1. After activation, you'll see a new menu item "Bidda School" in your WordPress admin
2. Click on "Settings" under the Bidda School menu
3. Configure your database connection settings:
   - Database Host (usually localhost)
   - Database Name (your existing Bidda database)
   - Database Username
   - Database Password
   - Bidda Installation Path

### 4. Integrate Existing Bidda System

If you have an existing Bidda installation:

1. Upload your existing Bidda files to a directory within your WordPress installation
   (e.g., `/wp-content/bidda/`)
2. Update the database connection settings in the plugin to match your existing Bidda database
3. Use the integration functions to connect WordPress users with Bidda users

### 5. Create WordPress Pages for Bidda Features

You can create WordPress pages that load your Bidda files using shortcodes:

1. Create a new page in WordPress
2. Use shortcodes like:
   - `[bidda_page file="login.php"]` for the login page
   - `[bidda_page file="fees/my_fees.php"]` for the fees page
   - `[bidda_page file="students/profile.php"]` for student profiles

### 6. User Synchronization

To synchronize WordPress users with Bidda users:

1. Go to the Bidda School admin menu
2. Click on "User Synchronization"
3. Run the synchronization process to create matching users in both systems

## Customization Options

### Adding New Features

To add new features to the WordPress integration:

1. Create new methods in the `Bidda_Admin` and `Bidda_Public` classes
2. Add new shortcodes in the `Bidda_Public` class
3. Create new admin pages by adding submenu items in `Bidda_Admin`

### Styling

To customize the appearance of Bidda pages within WordPress:

1. Add CSS files to an `assets/css/` directory in your plugin
2. Enqueue them in the `enqueue_styles` method of `Bidda_Public`
3. Use WordPress CSS classes to maintain consistency with your theme

## Troubleshooting

### Common Issues

1. **Database Connection Errors**
   - Verify database credentials in plugin settings
   - Ensure the database server is accessible
   - Check that the Bidda database tables exist

2. **Shortcodes Not Working**
   - Make sure the plugin is activated
   - Check that shortcode names are spelled correctly
   - Verify that the Bidda files exist at the specified paths

3. **User Synchronization Failures**
   - Ensure both WordPress and Bidda databases are accessible
   - Check user table structures in both systems
   - Verify that database permissions allow INSERT operations

### Getting Help

If you encounter issues:

1. Check the WordPress debug log for error messages
2. Verify that all file paths are correct
3. Ensure proper file permissions on your server
4. Contact support if problems persist

## Advanced Integration

For more advanced integration, consider:

1. **Single Sign-On (SSO)**: Implement a unified login system
2. **Data Synchronization**: Automatically sync data between systems
3. **Custom Post Types**: Create WordPress post types for Bidda entities
4. **REST API Integration**: Use WordPress REST API for data exchange

## Security Considerations

1. Always validate and sanitize user input
2. Use WordPress nonce verification for forms
3. Implement proper user role checking
4. Sanitize output to prevent XSS attacks
5. Use prepared statements for database queries
6. Regularly update the plugin and WordPress core

## Performance Optimization

1. Implement caching for frequently accessed data
2. Optimize database queries
3. Minimize HTTP requests
4. Use WordPress transients for temporary data storage
5. Implement lazy loading for heavy components

## Backup and Maintenance

1. Regularly backup both WordPress and Bidda databases
2. Keep the plugin updated with security patches
3. Monitor error logs for issues
4. Test updates in a staging environment first