# WordPress Plugin (PHP 8+)

Built for PHP 8+ WordPress and WooCommerce sites, clients/wordpress-plugin injects Consent Banner v2 in wp_head, bridges choices into the WP Consent API, and embeds hosted DPDP notices via shortcodes.

## Installation & settings

1. Package or upload clients/wordpress-plugin/policygrain-dpdp into wp-content/plugins/.
2. Activate PolicyGrain DPDP Consent & Notices in WordPress Admin > Plugins.
3. Open Settings > PolicyGrain DPDP and enter your Site Key. Optionally set your hosted notice URL, your grievance or rights page URL, and whether to show the notice on WooCommerce checkout. The CDN host and API origin default to https://cdn.policygrain.com and https://api.policygrain.com.
4. Nothing loads on the front end until a Site Key is saved. The plugin then adds <script src="https://cdn.policygrain.com/b/v1/loader.js" data-pg-site="…"> at priority 1 in wp_head, ahead of analytics and marketing tags.
5. If WP Consent API is active, PolicyGrain automatically publishes category states (functional, statistics, marketing, preferences) to compatible plugins including WooCommerce.

## Shortcodes for hosted notices and grievance links

```html
<!-- Link to your hosted notice, plus a button that reopens the banner to manage or withdraw consent -->
[policygrain_notice url="https://pages.policygrain.com/example-privacy" label="Read our DPDP Privacy Notice" manage_label="Manage or withdraw consent"]

<!-- Link to your rights and grievance page, with an optional email contact -->
[policygrain_grievance url="https://pages.policygrain.com/example-rights" label="Exercise DPDP Rights or File a Grievance" email="grievance@example.in"]
```

Both shortcodes fall back to the notice URL and grievance URL saved in Settings > PolicyGrain DPDP when url is left out, and render nothing if no https URL is available. The manage button carries data-pg-open, so a click calls the banner's own open(): the withdraw view after a choice, the first layer before one.
