// Help & Support — the guides bundled with this version of Dashbread (Dashbread Pro swaps in the live
// dashbread.com knowledge base), a developers' hooks reference, and Contact support (a Pro service;
// Core points to the WordPress.org forum). Core itself contacts no other site.
import { useEffect, useMemo, useRef, useState } from 'react';
import { __, _n, _x, sprintf } from '@wordpress/i18n';
import { cfg } from '../api.js';
import { Badge, Button, Card, Field, Icon, Notice, Spinner, toast } from '../ui.jsx';
async function call(path, opts = {}) {
const res = await fetch(cfg.rest + path, { credentials: 'same-origin', headers: { 'X-WP-Nonce': cfg.nonce, 'Content-Type': 'application/json' }, ...opts });
const data = await res.json().catch(() => ({}));
if (!res.ok) { const e = new Error(data?.message || sprintf( /* translators: %s: HTTP status code */ __('Request failed (%s)', 'dashbread'), res.status )); e.data = data?.data; throw e; }
return data;
}
// One shortcode with one-click copy (and a second button for the closing tag of enclosing tags).
function ShortcodeRow({ s }) {
const [copied, setCopied] = useState('');
const copy = async (text, which) => {
try { await navigator.clipboard.writeText(text); }
catch { const t = document.createElement('textarea'); t.value = text; document.body.appendChild(t); t.select(); document.execCommand('copy'); t.remove(); }
setCopied(which); setTimeout(() => setCopied(''), 1400);
};
const tag = (text, which) => (
{text}
);
return (
{s.note}
}{sec.note}
} {sec.items.map((s) =>' + __('This guide is not available. Read it on dashbread.com.', 'dashbread') + '
')).finally(() => setBusy(false)); } if (open && ref.current) ref.current.scrollIntoView({ block: 'nearest', behavior: 'smooth' }); }, [open]); return ({__('No guides are available here.', 'dashbread')} {/* translators: followed by a link to dashbread.com/help */ __('The full knowledge base is at', 'dashbread')} dashbread.com/help.
{sprintf( /* translators: %s: search terms */ __('Nothing matches “%s”.', 'dashbread'), q )} {/* translators: followed by the link text "search on dashbread.com" */ __('Try another word, or', 'dashbread')} {__('search on dashbread.com', 'dashbread')}.
} {byCat.map(([c, arr]) => ({c.description}
}{__('These guides ship with this version of Dashbread.', 'dashbread')} {/* translators: followed by a link to dashbread.com/help */ __('The latest versions are on', 'dashbread')} dashbread.com/help.
} {kb && !hasScGuide && scSections.length > 0 && ({__('Paste these into any page or post (or a Shortcode block).', 'dashbread')} {/* translators: followed by the button name "Copy" */ __('Click', 'dashbread')} {_x('Copy', 'button', 'dashbread')} {/* translators: follows "Click Copy" */ __('next to a tag.', 'dashbread')}
{__('Everything below works with Core alone.', 'dashbread')} {/* translators: followed by the guide name "Hooks & filters" */ __('Full reference: the', 'dashbread')} {/* translators: follows "Full reference: the Hooks & filters" */ __('guide above.', 'dashbread')} {/* translators: followed by the link text "Shortcode reference" */ __('Page builders: the', 'dashbread')} .
{`// Register a native page (renders inside the shell at /${route}/reports)
add_action( 'dashbread_register', function ( $r ) {
$r->register_page( 'reports', [
'title' => 'Reports',
'icon' => 'chart-line', // any Lucide icon name
'position' => 40,
'render' => fn() => 'Hello',
] );
$r->register_notification_type( 'invoice', [ 'label' => 'Invoices', 'icon' => 'receipt' ] );
$r->register_header_item( 'jobs', [ 'icon' => 'briefcase', 'label' => 'Jobs', 'toggle' => 'flyout', 'tab' => 'jobs', 'badge' => fn() => 3 ] );
} );
// Notify a member (in-app; Pro adds email)
dashbread_notify( $user_id, 'invoice', [ 'title' => 'Invoice #1042 is ready', 'url' => home_url( '/${route}/invoices/1042' ) ] );
// Add a screen under the Dashbread wp-admin menu, then mount it from your bundle:
add_filter( 'dashbread_admin_screens', fn( $s ) => $s + [ '-jobs' => [ 'Jobs', 'jobs' ] ] );
// window.DashbreadAdmin.registerScreen( 'jobs', JobsComponent );`}
{__('Priority email support — included with your Pro license.', 'dashbread')}
{sent &&{cfg.email || ''}.{__('Your system status (versions, route, entitlements, active plugins) is attached automatically to help us diagnose faster.', 'dashbread')}
{__('Free support for Dashbread is on the WordPress.org forum.', 'dashbread')} {/* translators: followed by the product name "Dashbread Pro" (a link) */ __('Priority email support from this screen is part of', 'dashbread')} Dashbread Pro{/* translators: follows the product name "Dashbread Pro"; keep the leading comma if your language uses one */ __(', sold separately.', 'dashbread')}
/{route}