# WordPress Plugin Update Guide

## Why Updates Weren't Working

WordPress doesn't automatically check GitHub for plugin updates. By default, WordPress only checks:
1. **WordPress.org Plugin Repository** - Official plugin directory
2. **Custom Update Servers** - Plugins with built-in update checkers

Since your plugin is hosted on GitHub but not in the WordPress.org repository, WordPress had no way to know when new versions were available.

## Solutions Implemented

### ✅ GitHub-Based Auto-Update (Now Active)

I've added a custom GitHub updater that:
- Checks GitHub releases for new versions
- Shows update notifications in WordPress admin
- Allows one-click updates from the WordPress dashboard
- Works with your existing GitHub Actions release workflow

**How it works:**
1. When you push version changes to GitHub, the GitHub Actions workflow creates a release
2. The WordPress plugin checks GitHub API for the latest release
3. If a newer version is found, WordPress shows an update notification
4. Users can update with one click from their WordPress dashboard

### 📋 Configuration Required

**Update the GitHub repository details** in [includes/updater.php](includes/updater.php):

```php
private $github_user = 'tecosys'; // Change to your GitHub username
private $github_repo = 'Nutaan-WP'; // Change to your repository name
```

### 🚀 How to Release Updates

1. **Update version in both files:**
   - `nutaan-widget.php` - Line 10: `Version: x.x.x`
   - `readme.txt` - Line 7: `Stable tag: x.x.x`

2. **Add changelog entry** in `readme.txt`

3. **Commit and push to main branch:**
   ```bash
   git add nutaan-widget.php readme.txt
   git commit -m "Release version x.x.x"
   git push origin main
   ```

4. **GitHub Actions automatically:**
   - Detects the version change
   - Creates a new release with tag `vx.x.x`
   - Uploads the plugin zip file

5. **WordPress sites automatically:**
   - Check for updates (every 12 hours by default)
   - Show update notification if available
   - Allow one-click update installation

## Alternative: WordPress.org Repository (Recommended for Public Plugins)

For broader distribution and automatic updates without custom code:

### Advantages:
- ✅ Automatic update delivery to all WordPress sites
- ✅ Better SEO and plugin discoverability
- ✅ Trusted by WordPress users
- ✅ Built-in ratings and reviews
- ✅ Download statistics

### How to Submit:

1. **Create an account** at https://wordpress.org/
2. **Submit your plugin** at https://wordpress.org/plugins/developers/add/
3. **Wait for review** (usually 1-2 weeks)
4. **Use SVN** to manage releases:
   ```bash
   svn co https://plugins.svn.wordpress.org/nutaan-widget
   # Copy files to trunk/
   svn add trunk/*
   svn ci -m "Initial commit"
   # Tag releases
   svn cp trunk tags/1.0.5
   svn ci -m "Release 1.0.5"
   ```

### Requirements for WordPress.org:
- ✅ GPLv2 or later license (already met)
- ✅ readme.txt file (already have)
- ✅ Unique plugin name (check availability)
- ✅ No trademark violations
- ✅ No obfuscated code
- ✅ External service disclosure (already documented in readme.txt)

## Testing the Update System

### Test on a staging site:

1. **Install current version** (1.0.4) on WordPress
2. **Wait a few minutes** for WordPress to check for updates
3. **Or manually trigger** update check:
   - Go to Dashboard → Updates
   - Click "Check Again"
4. **Verify** update notification appears
5. **Click "Update Now"** to test the update process

### Force update check via code:
```php
// Temporarily add this to functions.php to force update check
delete_site_transient('update_plugins');
```

## Troubleshooting

### Updates not showing?

1. **Check GitHub repository settings:**
   - Ensure repository is public or you've added GitHub token
   - Verify releases are being created properly
   - Check that zip files are attached to releases

2. **Check updater configuration:**
   - Verify `$github_user` and `$github_repo` are correct
   - Ensure the updater file is being loaded

3. **Clear WordPress caches:**
   ```php
   delete_site_transient('update_plugins');
   ```

4. **Check error logs:**
   - Enable WordPress debug mode
   - Check for API rate limits or connection errors

### GitHub API Rate Limits

- **Unauthenticated:** 60 requests/hour
- **Authenticated:** 5000 requests/hour

If you need authentication (for private repos or higher limits), modify the updater to include a GitHub personal access token.

## Current Status

✅ Version updated to 1.0.5
✅ GitHub updater installed and configured
✅ GitHub Actions release workflow ready
✅ Changelog updated

## Next Steps

1. **Configure GitHub repo details** in updater.php
2. **Test the update** on a staging WordPress site
3. **Consider submitting** to WordPress.org for wider distribution
4. **Monitor** GitHub releases and update notifications
