=== Reset file and folder permissions ===
Contributors: prakharb88
Donate link: https://nandann.com
Tags: permissions, security, files, directories, maintenance
Requires at least: 5.0
Tested up to: 7.0
Stable tag: 1.2.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Author: Prakhar Bhatia
Author URI: https://nandann.com

A WordPress plugin to reset file permissions to 0644, directory permissions to 0755, and file/folder ownership for security and maintenance purposes.

== Description ==

Reset file and folder permissions is a powerful yet safe WordPress plugin designed to help administrators reset file and directory permissions to their recommended secure values, and optionally reset file/folder ownership. This tool is particularly useful after site migrations, server changes, or when dealing with permission-related issues.

= Key Features =

* **Dual Functionality**: Reset both permissions (0644/0755) and ownership (user/group) in separate tabs
* **Ownership Management**: Change file and folder ownership to the correct web server user (VPS/dedicated servers)
* **Server Compatibility Check**: Automatically detects if ownership functions are available on your server
* **Batch Processing**: Handles large directory structures efficiently with configurable batch sizes
* **Real-time Progress**: Visual progress bar with detailed statistics during processing
* **Safety First**: Multiple security checks and confirmations before making changes
* **Selective Processing**: Choose specific directories to process (entire site, wp-content, plugins, themes, or uploads)
* **Smart Recommendations**: Automatically detects and recommends the correct owner/group for your server
* **Error Handling**: Comprehensive error logging and reporting
* **Responsive Interface**: Works seamlessly on desktop and mobile devices
* **Security Focused**: Only administrators can use this tool, with proper nonce verification

= Standard WordPress Permissions =

* **Files (0644)**: Owner can read/write, group and others can read only
* **Directories (0755)**: Owner can read/write/execute, group and others can read/execute

= When to Use This Plugin =

**For Permission Reset:**
* After migrating your WordPress site to a new server
* When files have incorrect permissions causing functionality issues
* For security hardening when permissions are too permissive
* When troubleshooting file access problems
* During routine maintenance to ensure proper permissions

**For Ownership Reset:**
* After migrating to a new server with a different web server user
* When WordPress cannot write files or install plugins/themes
* After manually uploading files via FTP with incorrect ownership
* When troubleshooting "permission denied" errors despite correct permissions
* When switching hosting providers or server configurations

= Safety Features =

* Requires explicit confirmation before processing
* Batch processing prevents server timeouts
* Real-time progress monitoring
* Comprehensive error logging
* Restricted to administrators only
* Path validation to prevent processing outside WordPress directory

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/reset-file-and-folder-permissions` directory, or install the plugin through the WordPress plugins screen directly.
2. Activate the plugin through the 'Plugins' screen in WordPress.
3. Navigate to 'Reset Permissions' in the main WordPress admin menu to access the plugin.

= Manual Installation =

1. Download the plugin zip file
2. Extract and upload the `file-permissions-reset` folder to your `/wp-content/plugins/` directory
3. Activate the plugin through the WordPress admin plugins page
4. Access the tool from the main admin navigation menu

= System Requirements =

**For Permission Reset:**
* PHP `chmod()` function must be available
* WordPress 5.0 or higher
* PHP 7.4 or higher
* Administrator access

**For Ownership Reset (Additional Requirements):**
* PHP `chown()` and `chgrp()` functions must be available
* PHP POSIX functions (`posix_getpwnam`, `posix_getgrnam`, etc.)
* VPS, dedicated server, or hosting with elevated privileges
* Note: Ownership features are typically NOT available on shared hosting

== Frequently Asked Questions ==

= Is this plugin safe to use? =

Yes, the plugin includes multiple safety measures:
- Requires administrator privileges
- Shows confirmation dialogs before processing
- Validates all paths to ensure they're within WordPress
- Processes files in batches to prevent timeouts
- Provides detailed error reporting

= Will this break my WordPress site? =

The permissions set by this plugin (0644 for files, 0755 for directories) are the WordPress recommended standards. However, some special files or custom configurations might require different permissions. Always backup your site before making changes.

= Can I undo the permission changes? =

No, permission changes cannot be automatically undone. This is why it's important to have a backup before running the tool. However, the plugin sets standard WordPress permissions that should work for most installations.

= What happens if the process is interrupted? =

The plugin processes files in batches, so if interrupted, only the current batch might be affected. You can safely restart the process, and it will continue from where it left off.

= Does this work on shared hosting? =

Yes, as long as your hosting provider allows the PHP `chmod()` function and you have sufficient file system permissions. The plugin will display an error if `chmod()` is not available.

= Can I process only specific directories? =

Yes, you can choose to process:
- Entire WordPress installation
- WP Content directory only
- Plugins directory only
- Themes directory only
- Uploads directory only

= What is file ownership and why does it matter? =

File ownership determines which user and group have control over files. In WordPress, files should typically be owned by the web server user (like www-data, apache, or nginx) to ensure proper functionality. Incorrect ownership can prevent WordPress from writing files, installing plugins/themes, or updating content.

= Why can't I see the ownership reset feature? =

The ownership reset feature requires PHP functions (`chown`, `chgrp`, and POSIX functions) that are often disabled on shared hosting for security reasons. These functions typically require elevated server privileges and are only available on VPS, dedicated servers, or hosting environments where you have more control. If you don't see the ownership tab or see a compatibility warning, contact your hosting provider or consider upgrading to a more flexible hosting solution.

= How do I know which owner and group to use? =

The plugin automatically detects your web server's user and group and recommends them. In most cases, you should use the recommended values. Common web server users include: www-data (Ubuntu/Debian), apache (CentOS/RHEL), nginx (Nginx servers), or _www (macOS).

= Can incorrect ownership break my site? =

Yes, setting incorrect ownership can prevent WordPress from functioning properly. Always use the recommended values provided by the plugin. If you're unsure, contact your hosting provider or a WordPress professional before making ownership changes.

= What's the difference between permissions and ownership? =

**Permissions** (0644/0755) control what actions can be performed on files (read, write, execute) by the owner, group, and others. **Ownership** determines which user and group "own" the files. Both need to be correct for WordPress to function properly. You can have correct permissions but still face issues if ownership is wrong.

== Screenshots ==

1. Main plugin interface showing system information, directory selection, and permission reset functionality
2. Ownership reset tab with server information and ownership configuration options
3. Progress bar during permission reset operation showing real-time processing statistics
4. Scan results and completion status with detailed file and directory counts

== Changelog ==

= 1.2.0 =
* Added: Full WP-CLI support for scanning, resetting permissions, and resetting ownership directly from the command line
* Compatibility: Tested and verified compatible with WordPress 7.0 "Armstrong"
* Update: Bumped tested up to version to WordPress 7.0

= 1.1.1 =
* Added: Screenshots for better plugin visibility on WordPress.org
* Updated: Tested up to WordPress 6.9
* Improved: Screenshot descriptions in readme.txt

= 1.1.0 =
* Added: File and folder ownership reset functionality
* Added: Separate "Reset Ownership" tab for ownership management
* Added: Automatic detection of web server user and group
* Added: Server compatibility check for ownership functions
* Added: Smart recommendations for owner/group selection
* Added: Dropdown menus for selecting owner and group
* Added: Comprehensive warnings and help text for ownership operations
* Added: Separate confirmation dialogs for ownership changes
* Improved: Tab-based navigation for better organization
* Improved: Enhanced error messages and logging
* Improved: Better compatibility warnings for shared hosting
* Note: Ownership features require VPS/dedicated server with elevated privileges

= 1.0.0 =
* Initial release
* Batch processing with progress tracking
* Directory-specific processing options
* Comprehensive error handling and logging
* Responsive admin interface
* Security hardening features

== Upgrade Notice ==

= 1.2.0 =
Major update: Full WP-CLI support added for scanning, resetting permissions, and resetting ownership directly from the command line. Tested and verified compatible with WordPress 7.0.

= 1.1.1 =
Minor update: Added screenshots and updated WordPress compatibility to 6.9. Recommended for all users.

= 1.1.0 =
Major update: Added file and folder ownership reset functionality with automatic server detection and smart recommendations. New tab-based interface for better organization. Ownership features require VPS/dedicated server.

= 1.0.0 =
Initial release of Reset file and folder permissions plugin. Safely reset file and directory permissions to WordPress standards.

== Support ==

For support, feature requests, or bug reports:
* Email: prakhar@nandann.com
* Website: https://nandann.com
* Subject: WordPress Development Help Request

Professional WordPress development and troubleshooting services available. Expert solutions for complex WordPress challenges including custom development, site migrations, security audits, and performance optimization.

== Development ==

This plugin is developed with security and reliability in mind. All user inputs are sanitized, permissions are validated, and operations are logged for transparency.

= Technical Details =

* Uses WordPress native functions and hooks
* Implements proper AJAX handling with nonce verification
* Follows WordPress coding standards
* Includes comprehensive error handling
* Responsive design using WordPress admin styles

== Privacy ==

This plugin does not collect, store, or transmit any personal data. All operations are performed locally on your server, and no data is sent to external services.

== About the Developer ==

**Prakhar Bhatia** is a professional WordPress developer and troubleshooter with extensive experience in:

* **WordPress Troubleshooting**: Expert diagnosis and resolution of complex WordPress issues, performance optimization, and security hardening
* **Custom Development**: Bespoke WordPress plugins, themes, and custom functionality tailored to specific business needs  
* **Site Migration & Hosting**: Seamless website migrations, hosting optimization, and server configuration for peak performance
* **Security & Maintenance**: Comprehensive security audits, malware removal, and ongoing maintenance to keep sites secure

**Nandann Creative Agency** specializes in WordPress development solutions for businesses of all sizes.

Contact: prakhar@nandann.com | Website: https://nandann.com

== Credits ==

Built with security and usability in mind, following WordPress development best practices. Developed by Prakhar Bhatia at Nandann Creative Agency. 