=== ASB Smart Flow ===
Contributors: asobit
Tags: mobile, admin, smartphone, ai, dashboard
Requires at least: 6.6
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 2.24.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A free, fully-featured mobile WordPress admin with AI authoring (BYOK), passkey login and tight integration with the ASB plugin family.

== Description ==

ASB Smart Flow turns the WordPress admin into a fast, one-handed mobile experience and adds an AI authoring workflow. Visit `/mobile-admin/` on a phone and you get a native-feeling SPA instead of the cramped default wp-admin. Every feature ships in one free build — no paid tier, no license activation.

= Everything you get =

* **Bottom tab bar** — [Home] [New Post] [Media] [Settings] reachable with your thumb.
* **Mobile-optimised uploader** — camera + multi-select, with on-device resize/compression before upload to save bandwidth.
* **AI authoring (BYOK)** — generate, rewrite, summarise, proofread and suggest titles with your own API key for OpenAI, Google Gemini, or Anthropic Claude. No data passes through our servers; the request goes directly from your WordPress site to the provider you selected.
* **Quick Post and templates** — fill-in-the-blank post templates with writing-style presets and quick instructions, all editable from the AI tab.
* **Emoji tray + snippets** — insert favorite emoji and reusable boilerplate (signature, hours, hashtags…) with one tap.
* **Passkey login (WebAuthn / FIDO2)** — sign in with Face ID / fingerprint on your phone from `/mobile-admin/login`. On desktops, `wp-login.php` gains a passkey button when the computer has a built-in authenticator (Touch ID / Windows Hello); otherwise you sign in with your normal WordPress password.
* **Voice dictation** — tap the microphone in the composer and speak; the transcript drops in at the caret, and one tap has the AI tidy it into clean prose (BYOK).
* **Comment moderation** — approve, unapprove, reply to, and trash comments right from the phone (for accounts that can moderate).
* **Offline draft protection** — the composer keeps a local backup of unsent edits on the device and offers to restore it after a dropped connection or an accidental close.
* **Body images + `[asbsmfl-img]` / `[asbsmfl-gallery]` shortcodes** — insert images and multi-column galleries at the cursor from the toolbar, then adjust each image's width (100 / 50 / 33 / 25%) and caption from the "Body images" panel.
* **PC desktop AI** — the same AI editor lives in a "✨ AI Writer" meta box on the post edit screen and on the AI tab in wp-admin.
* **Site accent color** — set a per-site identification color reflected on headers and primary buttons (preset palette + free-form hex).
* **Hamburger drawer** — quick links to the parts of wp-admin you rarely touch.
* **Auto-redirect (optional)** — mobile visitors hitting wp-admin get sent into the mobile UI.
* **QR code for the mobile URL** — Settings → General shows a QR code and PNG download so you can hand off the mobile link from desktop.
* **English + Japanese UI** — the React app and admin screens are fully translated; other locales fall back to English.
* **HTTPS only** — the plugin refuses to operate on insecure origins.

= ASB plugin family integration =

ASB Smart Flow auto-detects sibling plugins and surfaces their per-post toggles in a "📢 Delivery & Integrations" accordion on the new-post screen:

* **ASB PWA Engine** — push notification toggle, per-post.
* **ASB Calendar Advance** — show on calendar / Google Calendar button.
* **ASB LINE Notification** — LINE push, with image / thumbnail / image-first toggles.
* **ASB Post Thumbnail Pro** — per-post enable / disable override.
* **Jetpack Publicize** — detected when active.

These integrations work with both the free and Pro versions of each sibling plugin. The Pro tiers of those plugins add scheduling, image automation, and other extras — see https://shop.asobit.jp/ if you want to extend the workflow further.

= AI and data flow =

ASB Smart Flow only calls AI providers when **you** add an API key (in the plugin, or site-wide via WordPress 7.0's Settings → Connectors) and press Generate. Free without any key means zero outbound HTTP.

AI is **administrator-only by default**. Since the requests spend the site owner's API key, other roles can use AI only after an administrator explicitly delegates it on the "Permissions & AI" tab.

* Your API key is encrypted at rest on your own site (AES, key derived from your site's `AUTH_KEY` secret) and is never sent anywhere except the provider you chose.
* When you press "Generate", the post content / instructions / selected style are sent **directly from your WordPress install** to the provider endpoint (`api.openai.com`, `generativelanguage.googleapis.com`, or `api.anthropic.com`). Each provider's privacy policy applies to that data.
* Asobit LLC does not receive or proxy any AI request.

= External services =

The plugin contacts external services only when you enable or use the corresponding feature. With none of them in use it makes zero outbound calls.

* **OpenAI (opt-in, BYOK)** — `api.openai.com`. Sent: the prompt, post text, and any reference text/images you attach, plus your own API key. Terms: https://openai.com/policies/ Privacy: https://openai.com/policies/privacy-policy/
* **Google Gemini (opt-in, BYOK)** — `generativelanguage.googleapis.com`. Sent: same as above. Terms: https://ai.google.dev/gemini-api/terms Privacy: https://policies.google.com/privacy
* **Anthropic Claude (opt-in, BYOK)** — `api.anthropic.com`. Sent: same as above. Terms: https://www.anthropic.com/legal/consumer-terms Privacy: https://www.anthropic.com/legal/privacy
* **Google Drive image import (opt-in)** — when you import an image from Drive, your server downloads it from `drive.google.com` / `www.googleapis.com`. If you additionally configure a Google API key + OAuth client ID, the browser loads the Google Picker SDK from `apis.google.com` and `accounts.google.com` when the Drive picker is opened. Terms & privacy: https://policies.google.com/
* **Voice dictation** — uses the browser's built-in Web Speech API. Depending on the browser/OS, spoken audio may be processed by the browser vendor's speech service (e.g. Google on Chrome, Apple on iOS). Nothing is sent to Asobit LLC.

= Source & translation =

* The human-readable source of the compiled React app (`build/index.js`) ships inside the plugin under `app-src/`. Rebuild with `npm install && npm run build` in the plugin directory (uses `@wordpress/scripts`; Tailwind/PostCSS configs are included).
* Translations: contributions welcome through the WordPress.org translate platform.

== Installation ==

1. Upload the `asb-smart-flow` directory to `/wp-content/plugins/`, or install via Plugins → Add New.
2. Activate the plugin.
3. Open **ASB Smart Flow** in the wp-admin sidebar and choose your accent color and auto-redirect preference.
4. On your phone, visit `https://<your-site>/mobile-admin/`. (The Settings → General tab shows a QR code that opens this URL directly.)

== Frequently Asked Questions ==

= Who can use the mobile admin? =

Logged-in users with the `edit_posts` capability. You can change this with the filter `asbsmfl_required_capability`.

= Can I change the `/mobile-admin/` URL? =

Not yet. Avoid creating a page with the slug `mobile-admin` to prevent a collision.

= Does the plugin make external network calls? =

Only when you opt in. Without an AI key configured, the plugin's server-side code makes no outbound HTTP — except when you explicitly import an image from Google Drive, which downloads that file from Google. With an AI key, AI generate calls go directly to the provider you selected. See the "External services" section for the full list.

= Is HTTPS required? =

Yes. The plugin refuses to render on insecure origins, and passkey (WebAuthn) sign-in requires a secure context. (Smart Flow itself ships no Service Worker or push feature — those belong to the companion ASB PWA Engine plugin.)

= Which AI providers are supported? =

OpenAI, Google Gemini, and Anthropic Claude. You choose one and supply your own API key (BYOK). On WordPress 7.0 and later, a key saved once under Settings → Connectors is picked up automatically, so you don't have to enter it in the plugin at all — a key entered in the plugin overrides the connector for Smart Flow only. The model picker offers a curated list of current models per provider, and you can also type any model ID manually.

= Where is my AI API key stored? =

Encrypted in the `wp_options` table on your own site, with a key derived from your site's `AUTH_KEY` secret. It's only decrypted in memory at request time. You can rotate or remove it from the AI tab at any time, and it is deleted when the plugin is uninstalled.

= Can I use this with translation plugins? =

Yes. ASB Smart Flow loads its own `asb-smart-flow.pot` / `.po` / `.json` files from `languages/` and respects `get_user_locale()`. The React bundle calls `wp.i18n.setLocaleData()` so per-user locales work in the mobile app too.

== Screenshots ==

1. The mobile dashboard with post stats and recent posts.
2. New Post screen with featured-image preview and media tools.
3. AI Writer sheet — mode, instructions, reference material, length and tone.
4. AI writing result with title suggestions and a body preview.
5. AI settings — bring your own OpenAI / Gemini / Claude key.
6. ASB plugin family integrations.

== Changelog ==

= 2.24.4 =
* Fixed: the purchase and upgrade links all led to a page that does not exist. Nothing has been published to the shop yet, so every "Upgrade to Pro" / "Purchase License" button answered 404 — which reads as a broken plugin rather than an unfinished shop. Those links now stay off the screen until the product is actually on sale, while the wording that explains what a licence unlocks stays exactly where it was. The same rule now applies to the ASB family cards in the sidebar: a sibling is only shown once there is a page to send someone to.

= 2.24.3 =
* Fixed: the mobile app address /mobile-admin/ (and its login page) stopped opening on sites that updated to 2.24.x in place — the address quietly redirected to the home page instead. WordPress caches the whole set of address rules and only rebuilds that cache when a plugin is activated or the Permalinks screen is saved; updating a plugin is neither, so the cached rule still pointed at the internal name the app had before 2.24.0. WordPress discarded the unknown name, the address resolved to nothing, and the visitor was sent to the front page with no error shown anywhere. The plugin now rebuilds that cache as soon as it notices the mismatch.

= 2.24.2 =
* Fixed: the "ASB family" cards read the state of sibling plugins wrongly. A plugin that was installed but deactivated was shown as if it were not installed at all, and a Pro edition whose licence was not active was labelled FREE and offered for sale. Both now have their own card, with the right next step (activate the plugin / activate the licence).
* Fixed: siblings running a licensed Pro edition were dropped from the Dashboard family strip entirely, so an installed plugin looked missing. Every family plugin on the site is now listed.
* Added: ASB Smart Guide appears in the family cards on sites where it is installed.
* Fixed: the LINE Notification card listed "messages with thumbnails" as a free feature — sending the featured image is part of its Pro edition.
* Changed: family cards no longer link to WordPress.org pages or shop pages for plugins that are not published or on sale yet. Until each one goes live its card appears only on sites that already have it, as a plain status card.

= 2.24.1 =
* Fix: Keep the sibling-plugin panels working after ASB PWA Engine 2.16.0, ASB Calendar Advance 2.14.0 and ASB LINE Notification 2.9.0 moved to their new prefixes. Their post meta, options and helper functions are now resolved at runtime, so Smart Flow works with either the old or the new version of each.

= 2.24.0 =
Internal rename requested by the WordPress.org plugin review team: every class, constant, option, hook, script handle and shortcode moved from the `asb_sf_` prefix to `asbsmfl_`, which is long enough to be collision-proof against the other 100,000 plugins in the directory. Behaviour is unchanged.

* Changed: the body-image shortcodes are now `[asbsmfl-img]` and `[asbsmfl-gallery]`. Posts that already contain the old tags are rewritten automatically on the first load after upgrading — nothing to do by hand.
* Changed: stored data moves to the new names on that same first load — settings, AI provider settings (your API key stays encrypted and readable), the passkey credentials table and the image-tray post meta.
* Changed: filters and actions were renamed to match, e.g. `asb_sf_required_capability` is now `asbsmfl_required_capability`. Custom code hooking into this plugin needs the new names; nothing else is affected.
* Fixed: the mobile admin skin printed its accent-colour CSS variables as a raw `<style>` tag instead of attaching them to its stylesheet with `wp_add_inline_style()`.
* Fixed: the shared helper trait declared class constants, which is a fatal error on PHP 7.4 through 8.1 — the versions this plugin says it supports.
* Fixed: the two globals the uninstall routine defines while walking a multisite network were missing the plugin prefix.
* Fixed: the multisite migration checked its "already done" flag before switching to each site, so on a network only the main site was ever migrated.
* Dev: table names in the migration and uninstall routines now go through the `%i` identifier placeholder instead of being interpolated.

= 2.23.1 =
* Dev: all remaining inline `<script>` / `<style>` output now goes through `wp_register_*` + `wp_add_inline_*`, including the standalone mobile app shell, and script translations use `wp_set_script_translations()`.
* Dev: translations are delivered by WordPress language packs instead of a bundled catalogue, so the `languages/` folder and `Domain Path` header were dropped from the package.
* Dev: the packaged `Stable tag` now follows the plugin version automatically, and two `$_GET` reads plus one interpolated table name were tightened.

= 2.23.0 =
Security-hardening release ahead of the WordPress.org submission.

* Security: the mobile dashboard now limits posts and counts to the signed-in user's own posts for accounts that cannot edit others' posts (Contributor / Author), and site-wide comment totals are only returned to accounts that can moderate.
* Security: the unauthenticated passkey sign-in endpoint (`/webauthn/login/begin`) is now rate-limited per client and site-wide, answering HTTP 429 with a Retry-After header when flooded.
* Security: resource ceilings for imported content — Google Drive downloads are capped at 20 MB and 50 megapixels, Word (.docx) extraction rejects oversized archives before unpacking, PDF text extraction has a total decompression budget, and AI vision images are dimension-checked before decoding (with ImageMagick memory limits).
* Security: the AI settings endpoint is no longer readable by accounts that can neither use AI nor manage the settings, and its `canEdit` flag now honours the delegated settings role.
* Security: the passkey login cookie's Secure flag now follows the same HTTPS judgment used to allow the login, fixing sites behind TLS-terminating reverse proxies.
* Changed: **AI is now administrator-only by default.** Your API key is only spendable by other roles after you explicitly delegate on the "Permissions & AI" tab. Sites that already saved a choice there are unaffected.
* Changed: the "hide ASB family promotions" switch is now available to every site (it previously required owning a Pro sibling plugin).
* Fixed: the ASB Post Thumbnail link in the family sidebar pointed at a page that no longer exists; all family links now use their permanent URLs.
* Dev: JSON bootstrap payloads are HEX-escaped, unit-test files are excluded from the distribution, and the readme was aligned with the actual implementation.

= 2.22.3 =
* Fix: several interface strings stayed in English on Japanese sites — the Google Drive picker status and its setup hints, the family integration heading, and the auto featured-image preview card. The strings were already translatable; their Japanese translations were simply missing from the bundled catalogue and have now been added (13 strings).

= 2.22.2 =
* Fix: saving from the mobile composer could fail with "you are not allowed to edit the ... custom field" when a sibling plugin exposes read-only post meta over REST (e.g. LINE notification's send history). The composer now only submits custom fields shown in its own "additional fields" form instead of echoing back every field it loaded.

= 2.22.1 =
* Tweak: admin radio buttons show the native WordPress selected dot again - the branded yellow dot clashed inside the blue control.

= 2.22.0 =
* **Refreshed admin design.** The settings screen now wears the Asobit corporate palette: a clean white canvas with neutral greys, a near-black header bar, and the brand yellow for primary buttons and active states (buttons invert to black on hover). Layout and behaviour are unchanged — colours only. The site accent preset still applies to the visitor-facing app and is not affected.

= 2.21.0 =
* **New: WordPress 7.0 Connectors support.** If your site already stores an AI provider key under Settings → Connectors (or in an environment variable / PHP constant), Smart Flow now uses it automatically — no need to paste the same key into the plugin. Both the desktop AI Provider tab and the mobile settings card show a "Via WordPress Connectors" state for such providers, and the tip text steers new setups toward managing keys in core. A key entered in the plugin still overrides the connector for Smart Flow only, and everything keeps working unchanged on WordPress below 7.0.
* Switching between OpenAI / Gemini / Claude keeps working exactly as before, whichever place each key comes from; the provider picker now also counts connector-backed providers as ready to use.

Older entries: see `changelog.txt` inside the plugin folder.

== Upgrade Notice ==

= 2.24.0 =
Internal prefix rename (`asb_sf_` → `asbsmfl_`) requested by the WordPress.org review team. Settings, passkeys and the `[asb-img]` shortcodes already in your posts are migrated automatically. Only custom code hooking `asb_sf_*` filters needs updating.

= 2.23.0 =
Security hardening. Note: AI access now defaults to administrators only — if your authors used AI and you never saved the "Permissions & AI" tab, re-delegate the AI role there once after updating.

= 2.20.0 =
Voice dictation, on-phone comment moderation, and offline draft protection. Also fixes the newest OpenAI models. Safe update.

= 2.11.0 =
Consistent cross-promotion sidebar (constant layout; Pro siblings now show a review card). Safe update.

= 2.0.0 =
ASB Smart Flow is now 100% free — all previous Pro features ship in this build. Existing license activation is cleared automatically on upgrade.

= 1.15.0 =
Plugin renamed to ASB Smart Flow. Existing settings and credentials are migrated automatically on first activation — no manual steps required.

= 1.0.0 =
Initial release.
