=== Static Porter ===
Contributors: Kayıhan Turgutoğlu, Kaya Turk
Tags: static site generator, cloudflare, amazon s3, cdn, performance, page speed, security, seo
Requires at least: 5.0
Tested up to: 6.9
Requires PHP: 7.0
Stable tag: 4.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Convert WordPress to blazing-fast static HTML. Deploy to Cloudflare, AWS S3 + CloudFront, or download as ZIP. Safe for shared hosting.

== Description ==

**Static Porter** turns your WordPress site into pre-built HTML files, so visitors get instant page loads without your server ever touching PHP or a database.

Most caching plugins just speed up WordPress. Static Porter goes further: it generates a real, physical copy of your site that can be served on its own — from your own server via Apache, from Cloudflare's global edge network, from an AWS S3 bucket behind CloudFront, or as a downloadable ZIP you can host anywhere. Your live WordPress site stays completely private and secure behind the scenes; only the static HTML is ever exposed to visitors.

Built with shared and budget hosting in mind: a live "Peak Memory" monitor, a one-click "Stop Crawl" safety switch, and sensible defaults mean you're never one crawl away from taking your server down.

### Automated Maintenance (Smart Refresh)
Never worry about stale content. Static Porter watches your 'Publish' button. When you post, we instantly regenerate just that post and your homepage — keeping your site fast and fresh without you lifting a finger.

### Why choose Static Porter?
* **Deploy anywhere:** Not locked into one platform. Serve statically from your own Apache server, push to Cloudflare Workers, upload to AWS S3 with automatic CloudFront cache invalidation, or export a portable ZIP — pick whichever fits your infrastructure.
* **Built for real-world WordPress:** Works with page builders, shortcodes, and JavaScript-driven widgets. A built-in Documentation tab explains exactly what works out of the box and what needs a small adjustment first (forms, WooCommerce checkout, etc.).
* **Safe by default:** Every feature that could meaningfully change your site's output — Cloudflare deployment, S3 deployment, asset mirroring — is hidden until you explicitly turn it on. Nothing surprises you.

### Key Features

**Static generation & speed**
* **One-Click Full Crawl:** Generate a static version of your entire site in one click.
* **Server-Safe Crawling:** A real-time "Peak Memory" monitor and an emergency "Stop Crawl" button, designed for budget shared hosting where resources are limited.
* **Smart Refresh:** Publishing or updating a post automatically regenerates just that page and your homepage — no manual recrawling for routine edits.
* **Advanced Optimization:** Built-in HTML minification and Gzip compression.
* **Security & Caching:** Automatically configures .htaccess with security headers and browser caching rules.

**Deploy anywhere**
* **Cloudflare Deployment:** Push your static files straight to a Cloudflare Worker, serving your site from Cloudflare's global edge network. Hidden until you enable it.
* **AWS S3 + CloudFront Deployment:** Upload directly to an S3 bucket, with automatic CloudFront cache invalidation on every deploy. Hidden until you enable it.
* **Asset Mirroring:** Optionally copy your CSS, JavaScript, images, and fonts locally too, so a deployed or exported site works completely standalone — no dependency on your WordPress server staying online.
* **Download as ZIP:** Export your entire static site as a single ZIP file — perfect for local browsing, migrating hosts, or keeping an offline snapshot.

**Visibility & control**
* **Persistent Cache Table:** See every cached page with five independent actions per row: View, Recrawl, Copy URL, Exclude, and Delete — each with clear confirmation and feedback.
* **File Storage Location:** See exactly where your static HTML files live on disk, with a one-click "Copy path" button and a writable/not-writable status check.
* **Built-in Documentation:** A dedicated Documentation tab covers every feature — how it works, file locations, compatibility, deployment options, and FAQs — without ever leaving wp-admin.

== Installation ==

1. Upload the `static-porter` folder to the `/wp-content/plugins/` directory.
2. Activate the plugin through the 'Plugins' menu in WordPress.
3. Go to the 'Static Porter' menu in your sidebar.
4. Configure your excluded paths and click 'Start Full Crawl'.

== Frequently Asked Questions ==

= Will Static Porter really make my site faster? = 
Yes!
Traditional WordPress pages require the server to process PHP and query a MySQL database every time a visitor arrives.
Static Porter converts these into flat HTML files. Your server can then deliver these files instantly, bypassing the "heavy lifting" entirely.
This often results in a nearly instant Time to First Byte (TTFB).

= Will my URL structure or permalinks change? = 
No. This is one of the core strengths of Static Porter.
The plugin generates a static mirror of your site that follows your existing WordPress permalink structure perfectly.
Your visitors (and search engine bots) will continue to see the same clean URLs they always have, but the pages will simply load much faster.

= Do I have to manually recrawl my site every time I write a post? = 
No. Static Porter includes a "Smart Refresh" feature. When you publish or update a post, the plugin automatically regenerates the static version of that specific post and your homepage.
It’s a "set-and-forget" solution for active bloggers.

= Can I use this on a low-resource budget server? = 
Absolutely.
Static Porter is designed to be resource-efficient and includes a built-in "Peak Memory" monitor in the dashboard so you can track its impact.
If the crawl is too heavy for your server, you can use the "Stop Crawl" safety button at any time to immediately halt the process.

= Does this plugin improve my site's security? = 
Yes.
In addition to serving static files (which are inherently more secure than dynamic PHP), Static Porter automatically injects security headers into your .htaccess file.
This includes protection against clickjacking (X-Frame-Options) and MIME-type sniffing (X-Content-Type-Options).

= Will this help my Google search rankings (SEO)? = 
Speed is a major ranking factor for Google, especially with Core Web Vitals.
By serving ultra-fast static HTML and enabling Gzip compression and browser caching automatically, your site will likely see improved performance scores, which can lead to better visibility in search results.

= What happens if I want to remove a single page from the cache? = 
Unlike simple "purge all" plugins, Static Porter gives you a persistent cache table.
You can view a list of every cached URL and use individual "Delete" or "Recrawl" buttons for precise control without affecting the rest of your static site.

= Can I choose which parts of my site to make static? = 
Yes.
The dashboard allows you to toggle the crawling of Posts, Pages, Categories, and Tags independently.
You can also use the "Excluded Paths" box to prevent specific directories from ever being turned into static files.

= How do I know if it's working? =
Enable the "HTML Attribution" setting.
View your website's source code, and you will see a comment at the top confirming the page is being served as static HTML.

= Does this work with WooCommerce? =
It is recommended to exclude checkout, cart, and account pages using the "Excluded Paths" setting to ensure dynamic functionality remains intact.

= Can I deploy my static site to Cloudflare or AWS? =
Yes. Both are optional, hidden-by-default features. Cloudflare deployment pushes your static files to a Cloudflare Worker, serving your site from Cloudflare's global edge network. AWS S3 + CloudFront deployment uploads directly to your own S3 bucket, with automatic CloudFront cache invalidation on every deploy. Enable whichever fits your infrastructure from the dashboard settings.

= Do I need my WordPress site to stay online after deploying to Cloudflare or S3? =
By default, yes — only your HTML is deployed, so CSS, JavaScript, images, and fonts still load from your live WordPress site. Turn on Asset Mirroring if you want a fully standalone deployment that doesn't depend on WordPress staying online.

= What is Asset Mirroring? =
An optional setting that copies your CSS, JavaScript, images, and fonts locally alongside your static HTML, instead of leaving them to load from your live WordPress site. It's useful before deploying to Cloudflare, S3, or exporting a ZIP, since it makes the result fully self-contained. It's off by default because it increases crawl time and disk usage.

== Screenshots ==

1. One-click static generation with real-time progress bar.
2. Precise control: Delete or recrawl specific pages without clearing the whole cache.
3. Visualize your efficiency: See exactly how much database load you are bypassing.

== Upgrade Notice ==

= 4.1.0 =
Cloudflare deployment is now optional and hidden by default — enable it only if you need it. Added a much more thorough in-dashboard Documentation tab covering every feature of the plugin, plus a "New" badge and a dismissible callout pointing new users to it. Redesigned the Cached pages table with five separate row actions (View, Recrawl, Copy URL, Exclude, Delete) plus inline confirmation and feedback for each. Added optional AWS S3 + CloudFront deployment, alongside Cloudflare, both hidden until enabled. Added optional Asset Mirroring so deployed or exported sites can work fully standalone, without needing your WordPress site to stay online. The Download ZIP button is now disabled with a clear label until you've run at least one crawl.

= 4.0.0 =
New: File storage location card shows where your HTML files live on the server with one-click path copy. New: Download ZIP exports your entire static site as a single ZIP file for local browsing or uploading to any host.

= 3.5.9 =
Added one-click deployment of your static HTML files to Cloudflare's global edge network, and moved the crawl controls next to the other action buttons.

= 3.5.8 =
Dashboard redesign: clearer status header, grouped settings cards, live stats refresh with no page reload, and a search box for cached pages.

= 3.5.7 =
Bug fix: the post-crawl countdown could loop forever and repeatedly reload the page. It now reloads exactly once as intended.

= 3.5.6 =
Improved dashboard UX with clear Active/Inactive status indicators and removed automatic page reloads for better workflow.

== Changelog ==

= 4.1.0 =
* **Redesign:** Cloudflare deployment is no longer shown as an always-visible settings card. It now appears as a compact "Enable" card by default, and only expands into the full account ID / API token / worker name settings — and only shows the "Deploy to Cloudflare" button in the actions row — once you explicitly enable it. Existing Cloudflare credentials are preserved if you disable and later re-enable it.
* **New:** Added a Cloudflare-branded icon to the deployment card in place of the generic cloud icon.
* **New:** Added a "Documentation" tab directly on the plugin's own dashboard page (next to "Dashboard"), covering how the plugin works step by step, exact file storage locations, a compatibility guide (shortcodes, forms, sliders, WooCommerce, NGINX), and frequently asked questions — no need to leave wp-admin to understand what the plugin does.
* **Redesign:** The Cached pages table's single Delete/Recrawl toggle button has been replaced with five independent row actions: View (opens the generated static file directly), Recrawl (regenerates that page without deleting it first), Copy URL, Exclude (adds the page's path to Excluded Paths and removes its static file in one step), and Delete. Delete now shows an inline "Delete this static file?" confirmation in place of the row instead of deleting immediately, Recrawl shows a spinning icon and briefly disables the row while it runs, and Copy/Exclude flash a green checkmark to confirm the action completed.
* **Expanded:** The Documentation tab now covers every feature in the plugin across nine sections — How it works, Crawling and content, Performance and output, File locations, Cached pages actions, Cloudflare deployment, Download ZIP, Compatibility, and FAQ — instead of the original four thin sections.
* **New:** Added a red "New" badge on the Documentation tab, and a dismissible callout banner on the Dashboard pointing new users to it. Both automatically stop showing once you've visited the Documentation tab at least once, or if you dismiss the banner directly.
* **New:** Added optional AWS S3 + CloudFront deployment. Enable it from a collapsed settings card (matching the Cloudflare card's pattern, but visually distinct with an AWS-branded bucket icon and navy color treatment) to reveal fields for your AWS Access Key ID, Secret Access Key, S3 bucket name, region, and an optional CloudFront distribution ID. Deploying uploads your static files to S3 using hand-implemented AWS Signature Version 4 request signing (no AWS SDK dependency), and automatically invalidates your CloudFront cache afterward if a distribution ID is set.
* **New:** Added optional Asset Mirroring. When enabled, Static Porter downloads a local copy of every CSS, JavaScript, image, and font file a page references — including assets referenced inside CSS via url() and @import — and rewrites the page to point at those local copies. This makes ZIP exports and Cloudflare/S3 deployments fully standalone, no longer dependent on your WordPress site staying online to serve styling and images. A separate sub-option extends mirroring to external, third-party assets like Google Fonts. A warning banner appears near the deploy and download buttons whenever this is off and a deployment feature is active, so you know before you deploy rather than after.
* **Fix:** The "Download ZIP" button is now disabled and labeled "Crawl first to download as ZIP" until at least one page has been crawled, instead of being clickable and failing with an error afterward.
* **Docs:** Expanded the Documentation tab with two new sections, Asset Mirroring and S3 + CloudFront, and corrected the Cloudflare and Download ZIP sections to reflect that assets can now be included when Asset Mirroring is turned on.

= 4.0.0 =
* **New:** Added a "File storage location" settings card showing the full server path and browser-accessible URL of the static file cache, a writable/not-writable status indicator, a one-click "Copy path" button, and a direct "Open in browser" link.
* **New:** Added a "Download ZIP" button that packages your entire static HTML output into a single ZIP file and triggers an automatic browser download. Useful for local site browsing, migrating to a different host, or sharing a snapshot of the static output. Requires PHP's ZipArchive extension (available on all major hosts).

= 3.5.9 =
* **New:** Added a "Deploy to Cloudflare" option that uploads your generated static HTML files to a Cloudflare Worker, so they can be served entirely from Cloudflare's global edge network. Configure your account ID, API token, and worker name in the new "Cloudflare deployment" settings card.
* **Layout:** Moved Start full crawl and Stop crawl next to Purge cache in the main action row, instead of the page header.
* **Security:** The Cloudflare API token field no longer echoes the saved token back into the page source; leave it blank to keep the existing value.

= 3.5.8 =
* **Redesign:** Rebuilt the dashboard with a clearer status header, grouped settings cards (Content to crawl, Excluded paths, Performance & caching, HTML attribution), and icon-labeled toggles in place of the old stacked gray boxes.
* **No more page reloads:** Replaced the post-crawl countdown/reload with a "Refresh stats" action that updates the coverage, requests-avoided, memory, and disk-size figures in place via AJAX, with no full page reload at all.
* **Cached pages table:** Added a live search box to filter cached URLs, and fixed a bug where the "Start full crawl" button could stay stuck on "Crawling..." after a natural completion.

= 3.5.7 =
* **Bug Fix:** Fixed an infinite reload loop on the dashboard after a crawl completed. The post-crawl countdown timer was never stopped, so once it reached zero it kept counting into negative numbers and repeatedly tried to reload the page, leaving the browser stuck refreshing with no way to stop it short of closing the tab. The countdown now stops itself after triggering a single, clean reload.

= 3.5.6 =
* **UX Improvement:** Dashboard now clearly indicates active/inactive status with a "reassurance" message for new users.
* **Workflow:** Removed automatic page reload after crawling to allow reading of statistics.
* **Privacy:** HTML attribution comment is now opt-in by default.

= 3.5.5 =
* **HTML Attribution Fix:** Correctly outputs the verification message as an HTML comment on the first line of static pages.

= 3.5.4 =
* **New Icon:** Updated plugin branding to a professional "Porter/Package" box icon.
* **UI Refresh:** Restored sidebar labels and updated dashboard header icons.
* **Timer Update:** Reduced post-crawl auto-refresh from 10 seconds to 5 seconds for a faster workflow.

= 3.4.7 =
* Major fixes
* Added Stop Crawl functionality.
* Added individual row Delete and Recrawl buttons.
* Added 10-second auto-refresh after crawl.