# WordPress Deployment via FTP - Instructions

## Files to Upload to cPanel

### Required Files/Folders:
- /wp-admin/
- /wp-content/ (your themes, plugins, uploads)
- /wp-includes/
- index.php
- wp-activate.php
- wp-blog-header.php
- wp-comments-post.php
- wp-config.php (IMPORTANT: Update database credentials)
- wp-cron.php
- wp-links-opml.php
- wp-load.php
- wp-login.php
- wp-mail.php
- wp-settings.php
- wp-signup.php
- wp-trackback.php
- xmlrpc.php
- .htaccess

### Files to EXCLUDE (Don't upload):
- /wp-content/upgrade/
- /wp-content/cache/
- /wp-content/debug.log
- /wp-content/wpvividbackups/
- /wp-content/wpvivid_staging/
- Any backup files

## Steps:

### 1. Update wp-config.php for Production
Before uploading, update these in wp-config.php:
```php
// Database credentials from cPanel
define('DB_NAME', 'your_cpanel_database_name');
define('DB_USER', 'your_cpanel_database_user');
define('DB_PASSWORD', 'your_cpanel_database_password');
define('DB_HOST', 'localhost'); // Usually localhost on cPanel

// Change these to new random values (https://api.wordpress.org/secret-key/1.1/salt/)
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
// ... etc

// Site URL (your actual domain)
define('WP_HOME', 'https://yourdomain.com');
define('WP_SITEURL', 'https://yourdomain.com');

// Disable file editing in production
define('DISALLOW_FILE_EDIT', true);

// For production, set debug to false
define('WP_DEBUG', false);
```

### 2. Export Database from Local
1. Go to http://localhost/phpmyadmin
2. Select your WordPress database
3. Click "Export"
4. Choose "Quick" method
5. Save the .sql file

### 3. Create Database in cPanel
1. Login to cPanel
2. Find "MySQL Databases"
3. Create new database
4. Create new user with password
5. Add user to database with ALL PRIVILEGES
6. Note down: database name, username, password

### 4. Upload Files via FTP
Using FileZilla or any FTP client:
- Host: ftp.yourdomain.com (or IP from cPanel)
- Username: Your cPanel username
- Password: Your cPanel password
- Port: 21 (or 22 for SFTP)

Upload to: public_html/ or public_html/subdirectory/

### 5. Import Database in cPanel
1. Go to cPanel → phpMyAdmin
2. Select your new database
3. Click "Import"
4. Upload your .sql file
5. Click "Go"

### 6. Update URLs in Database
If your local URLs are different from production:
```sql
UPDATE wp_options SET option_value = 'https://yourdomain.com' WHERE option_name = 'siteurl';
UPDATE wp_options SET option_value = 'https://yourdomain.com' WHERE option_name = 'home';
```

### 7. Update Frontend .env
After deployment, update your Next.js .env:
```
NEXT_PUBLIC_WORDPRESS_API_URL=https://yourdomain.com/graphql
```

### 8. Test GraphQL Endpoint
Visit: https://yourdomain.com/graphql
You should see the GraphQL playground

## Troubleshooting:

### If you get "Error establishing database connection":
- Check database credentials in wp-config.php
- Verify database user has permissions
- Check if database exists

### If GraphQL doesn't work:
- Re-save permalinks: WordPress Admin → Settings → Permalinks → Save
- Check .htaccess file exists and is writable
- Verify WPGraphQL plugin is active

### If CORS errors persist:
- The mu-plugin (wp-content/mu-plugins/cors-handler.php) should handle it
- Update allowed origins if your domain changed
