MerchantDrafts · Docs

Business Context (Brand DNA)

How to set up brand context for AI generation.

Overview

Business Context is a plain-text brand profile — voice, positioning, target audience, and key values. It is automatically injected into every generation as the dominant baseline. All generated copy must stay within it.

Storage: mdrfts_business_context (WordPress option)

Timestamp: mdrfts_business_context_updated

Location: Settings → Brand tab → Business Context card

How It Is Created

Operators click Fetch from website — MerchantDrafts scrapes the site, sends content to Gemini, and generates a 3–5 paragraph plain-text brand profile (takes ~10 seconds).

The result is saved to the database automaticallyupdate_option( 'mdrfts_business_context', ... ) is called server-side before the AJAX response is returned. The textarea is then populated client-side from the response for review and optional editing.

Operators can also write or edit the profile directly in the textarea and click Save Manual Edits to persist changes.

UI — Button Map (Brand Tab)

ButtonTypeWhat it does
Fetch from websitePrimary (blue), left-alignedScrapes site → Gemini AI → saves to DB automatically → fills textarea
Save Manual EditsSecondary, right-alignedSubmits the form — persists any manual text edits to the textarea
Copy icon (dashicons-clipboard)Icon overlay, top-right of textareaCopies textarea content to clipboard; switches to dashicons-yes for 2 s then reverts
Trash icon (dashicons-trash)Icon overlay, top-right of textareaClears Business Context (separate hidden form with confirm dialog); only visible when a value exists

The copy and trash icons live inside .mdrfts-ta-toolbar — a position: absolute overlay that fades in on textarea hover or focus-within (opacity: 0 → 1). At rest it is invisible so it does not obstruct reading. The button row uses justify-content: space-between — Fetch on the left, Save Manual Edits on the right.

Loading Feedback

During a Fetch operation the button shows an inline spinner and its label changes to "Analysing website…". The status paragraph below the textarea uses three visual states:

A live word count (<span id="mdrfts-ctx-wordcount">) is shown below the textarea in soft grey, updated on every input event and after each successful fetch.

Spinner implementation

The spinner uses the dashicons-update icon + mdrfts-spin class — the same pattern as the product editor.

The @keyframes mdrfts-spin animation (rotate 0deg → 360deg, 0.7s linear infinite) is defined inline in the settings page <style> block. assets/style.css is only enqueued on post.php/post-new.php and is not available on the settings page.

Auto-height textarea

The business context textarea grows automatically to fit generated content.

CSS (primary): field-sizing: content with resize: none; overflow: hidden; min-height: 120px. Supported in Chrome 123+, Firefox 128+, and modern Safari.

JS fallback (mdrftsResizeCtx()): checks el.style.fieldSizing === 'content' and skips if the browser handles it natively. Otherwise uses el.style.height = 'auto'; el.style.height = scrollHeight + 'px'. Wired to page load, every input event, and after a successful AJAX fetch.

Textarea styling: font-size: 11px; line-height: 1.4; padding: 36px applied via the textarea.code CSS rule (the element carries class large-text code). Card body padding is 42px.

First-Run Nudge

On plugin activation, if Business Context is empty, a 30-day transient mdrfts_show_bc_nudge is set. An admin notice appears on every wp-admin page (for manage_options users only) with a "Set up Business Context" button linking to Settings. The notice:

The Business Context card also shows an inline empty-state callout when BC is not yet set: "No Business Context yet. Click Fetch from website below…"

Protection Against Accidental Deletion

Visibility in the Product Editor

Before generating, the operator can see Business Context status directly in the Advanced Options section of the controls sidebar — an Active (green) or Not set (amber) pill with an "Add in Settings" / "Edit in Settings" link to ?page=mdrfts_settings&tab=brand. Rendered in PHP at page load; no JS required.

After generating, the Info tab Active layers row confirms whether Business Context was injected, with a direct Settings link.

Prompt Role

Business Context is injected at layer 4 of the prompt stack, after product data and before Writing Pattern and Product Emphasis. It dominates all layers below it — all copy must stay within the brand baseline it defines.

In the workspace model, Business Context remains a shared mid-stack layer for outputs such as:

Do

Do Not

Do Not