=== Simple SEO Noindex Toggle ===
Contributors:      sibokul
Tags:              seo, noindex, robots, meta, search engine
Requires at least: 5.8
Tested up to:      6.9
Stable tag:        1.0.0
Requires PHP:      7.4
License:           GPLv2 or later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

A lightweight, professional SEO plugin — add a noindex robots tag to any post or page with a clean toggle, admin bar indicator, list column, bulk actions, and quick-edit support.

== Description ==

**Simple SEO Noindex Toggle** gives you precise, per-content control over which posts and pages are indexed by search engines — without the overhead of a full SEO plugin suite.

In one click, you can exclude any post or page from search engine indexes using the standard `<meta name="robots" content="noindex, nofollow">` tag. Every feature is built around a clean admin UI, WordPress coding standards, and zero unnecessary dependencies.

= Core Features =

**Noindex Toggle — Meta Box**

A clean "SEO Settings" meta box appears in the post and page editor sidebar. It includes:

* A smooth CSS toggle switch
* A live status badge ("Included in index" / "Excluded from index") that updates instantly without a page reload
* A tag preview showing the exact meta tag that will be output when noindex is active
* A built-in Tag Verifier button (on published posts)

**Built-in Tag Verifier**

A "Verify Tag in Source" button inside the meta box performs a live server-side HTTP request to the post's public URL and checks whether the robots meta tag is actually present in the page source — using PHP's DOMDocument parser for reliable, regex-free detection. Results display inline with three clear states:

* ✓ **Confirmed** — the noindex tag is live in the page source, showing the exact tag as found
* ⚠ **Not Found** — the tag is missing from source, likely a caching issue
* ✕ **Error** — the page could not be fetched (reason shown)

**Admin Bar Indicator**

A live SEO status badge appears in the WordPress admin bar showing:

* **● Noindex** (red) — this page is excluded from search indexes
* **● Indexed** (green) — this page is included in search indexes

Visible both on the frontend (when browsing any singular post or page) and inside the WordPress admin post editor. Clicking the badge takes you directly to the post edit screen.

**Post List Table Column**

A sortable "SEO" column on the Posts and Pages list tables. Each row shows a colored status badge — red "● Noindex" or green "● Indexed" — giving editors an instant full-site noindex audit at a glance without opening individual posts.

The column is sortable: click the column header to sort all noindexed content to the top.

**Bulk Actions**

Two new bulk actions in the Posts and Pages list tables:

* **SEO: Add Noindex** — enables noindex on all selected posts in one action
* **SEO: Remove Noindex** — clears noindex from all selected posts in one action

A dismissible admin notice confirms how many posts were updated after each bulk action.

**Quick Edit Support**

A "Noindex this post" checkbox appears inside the Quick Edit row — toggle noindex without opening the full post editor. The checkbox is automatically pre-populated with the current post's noindex status when Quick Edit opens.

**Settings Page**

Found under **Settings → Simple SEO Noindex**. Provides:

* Enable Plugin Globally — master on/off switch
* Enable for Posts — show meta box on posts
* Enable for Pages — show meta box on pages

= What Gets Output =

When noindex is enabled for a post or page, the following tag is added to `<head>` with priority 1 (near the very top, before any third-party tags):

`<meta name="robots" content="noindex, nofollow" />`

= Technical Highlights =

* **OOP architecture** — clean singleton classes with `SSN_` prefix throughout
* **No jQuery** — 100% vanilla JavaScript with the Fetch API
* **DOMDocument parsing** — Tag Verifier uses proper HTML parsing, not fragile regex
* **Secure** — nonce verification, `sanitize_text_field()`, `esc_attr()`, `esc_html()`, `current_user_can()` on every save operation
* **Clean uninstall** — all options and post meta removed on plugin deletion
* **Multisite compatible** — uninstall routine handles all subsites
* **Zero frontend footprint** — no scripts or stylesheets loaded on the public-facing site

= Who Is This For? =

SEO-focused site owners, developers, and marketing teams who need a precise, lightweight tool to manage content indexing without installing a full SEO plugin. Works standalone or alongside any existing SEO stack.

== Installation ==

**From the WordPress Admin (recommended):**

1. Go to **Plugins → Add New**.
2. Search for **Simple SEO Noindex Toggle**.
3. Click **Install Now**, then **Activate Plugin**.

**Manual Upload:**

1. Download the `simple-seo-noindex.zip` file.
2. Go to **Plugins → Add New → Upload Plugin**.
3. Select the ZIP file and click **Install Now**.
4. Click **Activate Plugin**.

**Manual FTP:**

1. Extract `simple-seo-noindex.zip`.
2. Upload the `simple-seo-noindex/` folder to `/wp-content/plugins/`.
3. Go to **Plugins → Installed Plugins** and activate.

**First-Time Setup:**

1. Go to **Settings → Simple SEO Noindex**.
2. Confirm **Enable Plugin**, **Enable for Posts**, and **Enable for Pages** are all checked.
3. Click **Save Settings**.
4. Open any Post or Page in the editor — the **SEO Settings** meta box appears in the right sidebar.
5. Toggle **Noindex this page** and save/publish the post.
6. Click **Verify Tag in Source** to confirm the tag is live in the page source.

== How to Verify the Plugin Is Working ==

There are three ways to confirm the noindex tag is active on the frontend:

**Method 1 — Built-in Tag Verifier (recommended)**

1. Enable the Noindex toggle on a published post and save.
2. In the editor, click **Verify Tag in Source** in the SEO Settings meta box.
3. A green ✓ Confirmed result appears, showing the exact tag found in the live page source.

**Method 2 — View Page Source**

1. Visit the published post on the frontend.
2. Right-click → **View Page Source** (or press `Ctrl+U` / `Cmd+U`).
3. Press `Ctrl+F` and search for `noindex`.
4. The tag `<meta name="robots" content="noindex, nofollow" />` appears near the top of `<head>`.

**Method 3 — Google Search Console**

1. Open **URL Inspection** in Google Search Console.
2. Paste the post URL and click **Test Live URL**.
3. Under **Page Indexing**, Google reports: *"Page is not indexed — noindex tag detected"*.
4. Under **HTTP response → Detected meta tags**, the robots tag is listed explicitly.

**Method 4 — site: Search Operator**

After Google recrawls the page (typically 24–72 hours), searching `site:yourdomain.com/post-slug` on Google returns no results, confirming the page has been de-indexed.

== Frequently Asked Questions ==

= The Tag Verifier shows "Not Found" even though the toggle is enabled. =

This is almost always a caching issue. The verifier sends a fresh request with a cache-busting query string and `no-cache` headers, but some caching plugins or CDNs may still serve a stale response. Purge your cache and click Verify again. You can also use Method 2 (View Page Source) to double-check directly.

= The Tag Verifier says "Could not fetch page source". =

WordPress uses `wp_remote_get()` which makes an outbound HTTP request from the server back to the post URL. On some localhost or restricted hosting environments, the server cannot reach itself. Use Method 2 (View Page Source) in these cases. The verifier works correctly on standard live and staging servers.

= Does this conflict with Yoast SEO, Rank Math, or AIOSEO? =

It outputs a robots meta tag directly into `wp_head` at priority 1. If another SEO plugin also outputs its own robots tag on the same post, both tags will appear in `<head>`. Search engines honour the most restrictive instruction, so having both is functionally harmless. To avoid duplication, use only one tool's noindex feature per post.

= Does it support custom post types? =

Version 1.0.0 supports Posts and Pages. Custom post type support is planned for a future release.

= Does the plugin add any custom database tables? =

No. It uses WordPress core's `wp_options` table for plugin settings and `wp_postmeta` for per-post noindex flags. No custom tables are created.

= What happens to my data if I delete the plugin? =

The `uninstall.php` routine removes all plugin settings (`ssn_settings` from `wp_options`) and all per-post noindex flags (`_ssn_noindex` from `wp_postmeta`). No orphaned data remains. The routine is multisite-aware and cleans up all subsites.

= Does this work with the Gutenberg block editor? =

Yes. The meta box renders correctly in the block editor sidebar panel. All features — toggle, status badge, tag preview — function identically in both the block editor and Classic Editor.

= Does the Quick Edit update noindex without a full page reload? =

Yes. WordPress Quick Edit submits via its own AJAX handler. The Noindex checkbox is included in that submission and processed via the standard `save_post` hook — no additional AJAX or custom endpoint required.

= Can I use this on a WordPress Multisite installation? =

Yes. Each subsite stores its own independent settings. The uninstall routine loops all subsites and removes all data cleanly.

= Does this plugin add any load to the frontend? =

No. The plugin loads no scripts or stylesheets on the frontend. The only frontend action is a single `get_post_meta()` call inside `wp_head` on singular pages — negligible performance impact.

= Will the plugin work if I have another SEO plugin installed? =

Yes. Simple SEO Noindex Toggle operates independently and does not interfere with other SEO plugins.

== Screenshots ==

1. **SEO Settings meta box** — editor sidebar with toggle switch, live status badge, tag preview, and Tag Verifier button.
2. **Tag Verifier — Confirmed** — green success result showing the exact robots tag from live page source.
3. **Tag Verifier — Not Found** — amber warning when the tag is missing (cache issue or toggle not saved).
4. **Admin Bar Indicator** — red "● Noindex" and green "● Indexed" badges on the frontend and in the post editor.
5. **Post List Table** — sortable "SEO" column with green "● Indexed" and red "● Noindex" badges per row.
6. **Bulk Actions** — "SEO: Add Noindex" and "SEO: Remove Noindex" in the bulk action dropdown.
7. **Quick Edit** — inline Noindex checkbox pre-populated from current post state.
8. **Settings Page** — global and per-post-type toggle controls with sidebar information panel.

== Changelog ==

= 1.0.0 =
* Initial release.
* Noindex toggle meta box on Posts and Pages with live status badge, tag preview, and smooth CSS toggle switch.
* Built-in Tag Verifier — server-side fetch using PHP DOMDocument HTML parsing for reliable robots meta tag detection; displays the exact tag found in the live page source.
* Admin Bar Indicator — live red/green SEO status badge on the frontend and inside the post editor admin bar.
* Post List Table Column — sortable "SEO" column with green/red colored status badges on Posts and Pages list tables.
* Bulk Actions — "SEO: Add Noindex" and "SEO: Remove Noindex" for Posts and Pages list tables with dismissible result notice.
* Quick Edit Support — Noindex checkbox inside Quick Edit row, auto-populated from current post state via vanilla JavaScript.
* Settings page under Settings → Simple SEO Noindex with global enable and per-post-type controls.
* 100% vanilla JavaScript — zero jQuery dependency, uses Fetch API.
* Full uninstall cleanup — removes all options and post meta on plugin deletion.
* WordPress Coding Standards compliant OOP singleton architecture with SSN_ prefix throughout.
* Multisite compatible.

== Upgrade Notice ==

= 1.0.0 =
Initial release. No upgrade steps required.
