=== MetricPage Builder ===
Contributors: yujesh
Tags: page builder, theme builder, header footer, performance, site builder
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 1.0.12
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Fast, lightweight page builder with server-side rendering. Build pages, headers, footers and single post templates with clean HTML and no bloat.

== Description ==

**MetricPage Builder** is a fast, lightweight WordPress page builder made for performance. Many drag-and-drop builders slow sites down with heavy markup and database bloat. MetricPage uses a schema-driven data model and a **server-side rendering (SSR) compile pipeline** instead, so visitors get clean, cached HTML.

It is made for developers, agencies and site owners who want speed, clean code and full control over their design system.

### Why Choose MetricPage Builder?

* **Fast page loads** – Pages are compiled to optimized HTML when you publish and served from a cache, so no builder rendering happens while visitors load the page.
* **Small database footprint** – Only the content you enter is saved, as compact data. No bloated post meta and no huge revision histories.
* **Clean HTML output** – Your theme defines the markup and CSS, so there is no "div soup" and no stray inline styles.
* **Lightweight editor** – A focused editing screen with live canvas previews that update instantly as you type.
* **Built for design systems** – Developers set the layout and styles. Editors fill in clear fields like Heading, Image and Button text and can't accidentally break the design.

### Theme Builder: Headers, Footers and Single Post Templates

Design your whole site with one builder, not just individual pages:

* **Custom headers and footers** – Build as many as you need and pick where each one appears.
* **Display conditions** – Show a header, footer or template on the entire site, the front page, specific pages or posts, post types, archives, categories, tags, search results or 404 pages. Exclude rules are supported, and the most specific match wins.
* **Single post templates** – Lay out blog posts with dynamic Post Title, Featured Image, Post Meta, Post Content and Author Box blocks that fill in automatically for every post.
* **Related posts** – Show posts from the same category under each article.

### Key Features

* Schema-driven page building with server-side rendering (SSR)
* Regenerable compile cache for fast front-end performance
* Build pages, headers, footers and single post templates
* Conditional display rules for theme parts
* Post List block: grid or list layout, category and tag filters, sorting and pagination
* Author Box with Facebook, X, Instagram, LinkedIn, YouTube and TikTok links
* Container component with responsive desktop, tablet and mobile settings
* Undo and redo
* Import and export page schemas as JSON
* Automatic WebP image optimization
* Works with classic themes and block themes
* Security built in: capability checks, nonces, signed shortcode markers and output filtering with wp_kses

### How It Works

1. Developers register components and styles in the theme.
2. Editors fill in structured fields in the Metric editor.
3. When you publish, the page is compiled into optimized HTML and cached.
4. Visitors are served the compiled HTML.

Compiled HTML is kept in a regenerable cache, not in `post_content`, which keeps your database clean.

### Who Is MetricPage Builder For?

**Developers and agencies:** Keep full control over markup, CSS and the design system on every client site. You define the components and the builder becomes a structured, lightweight editing screen.

**Clients and content editors:** A simple editing experience with no margin, padding or styling controls to learn. Fill in the fields, click Publish and the page matches the approved design.

**Performance-focused site owners:** If you care about Core Web Vitals, page speed scores and a lean database, MetricPage Builder keeps your front end light.

== Installation ==

1. Upload the `metricpage-builder` folder to the `/wp-content/plugins/` directory, or install it from **Plugins → Add New Plugin** by searching for "MetricPage Builder".
2. Activate **MetricPage Builder** through the **Plugins** menu in WordPress.
3. Activate a theme that registers Metric components (for example the companion **Metric Theme Kit**).
4. Go to **Pages** and click **Edit with Metric** to open the builder.
5. Build headers, footers and single post templates under **Metric → Theme Parts**.

== Frequently Asked Questions ==

= Can I build my header and footer with Metric? =

Yes. Go to Metric → Header & Footer, add a header or footer and build it in the same builder as your pages. You can create as many as you like and choose where each appears with display conditions: entire site, front page, blog page, search, 404, author/date archives, all singular content, a post type (all or specific items), all archives, a post type archive, or a taxonomy (all or specific terms). Exclude rules win; otherwise the most specific match wins, and ties go to the most recently updated part. Pages with no match keep your theme's default.

Your theme needs to print the part where it outputs its header or footer:

`<?php if ( ! function_exists( 'metric_builder_part' ) || ! metric_builder_part( 'header' ) ) { get_template_part( 'header-default' ); } ?>`

Themes can declare `add_theme_support( 'metric-site-parts' );` and seed their own header/footer components with the `metric_site_part_seed` filter.

= Does this replace the Block Editor (Gutenberg)? =
Yes, MetricPage Builder acts as a complete alternative to the default editor on the pages you choose to edit with it.

= Where is the data stored? =
The raw schema data is stored efficiently in post meta. The compiled SSR output is held in a regenerable cache (object cache, transient, or a file under `uploads/metricpage-builder/`) and injected into the page through a `the_content` filter, so your site remains unbelievably fast.

Note: the compiled HTML is not written back into the `post_content` column. Plugins that analyse the raw column directly (for example some SEO content analysers) will not see the rendered body.

== Screenshots ==

1. The MetricPage Builder editor interface.
2. The global settings panel for managing your design system.

== Changelog ==

= 1.0.12 =
* Fix: Component previews on Metric → Builder now load each component's own styles, so the built-in sections look right even without a theme kit.

= 1.0.11 =
* New: Template-style components. A component's render.php can be a plain template that prints ready-to-use, already-escaped field values (`$f`), with schema defaults filled in automatically. Function-style components keep working.
* New: Developer helpers `metric_template_fields()` and `metric_render_template()`.

= 1.0.10 =
* Changed: Default Single Post template layout order updated to Title -> Meta -> Featured Image -> Content -> Author Box -> Related Posts.
* Layout: Added container padding to `.metric-single` and centered `.metric-single-image` with clean responsive max-width containment.
* Fix: Eliminated PHP undefined array key notices in `PostBlocks.php` when image shape or content width attributes are omitted.

= 1.0.9 =
* New: Single Post templates. Design how blog posts look in the Metric builder (Metric → Theme Parts → Single Posts) and choose which posts use each template. A ready-made default layout is included. Works with block and classic themes.
* New: Post Title, Featured Image, Post Meta, Post Content and Author Box blocks, filled in for the post being viewed.
* New: Author Box with social links. Authors add Facebook, X, Instagram, LinkedIn, YouTube and TikTok links under Users → Profile.
* New: Post List can show posts related to the current post (same category).
* Changed: Metric → Header & Footer is now Metric → Theme Parts.
* Fix: Post List grids show one column on phones, and pagination links point to the right page.
* Fix: Post blocks stay empty on non-post pages; post embeds keep WordPress's embed view; caches rebuild after security salts change.

= 1.0.8 =
* New: Post List block. Show posts (or any public post type) in a grid or list, filtered by category and tag, with order, count, show/hide options and pagination. New posts appear without republishing the page.
* Security: Shortcode markers in compiled pages are now signed, so marker text typed into content can never run a shortcode.
* Developers: `metric_register_dynamic_block()` registers blocks rendered on every request; select fields accept `enumLabels`.

= 1.0.7 =
* Security: All front-end output, including shortcode output, is filtered with wp_kses before it is returned to the_content. Form elements are allowed so shortcode forms keep working; the list can be extended with the `metric_front_allowed_html` filter.
* Security: Settings inputs are sanitized field by field as they are read.
* Fix: Publishing a header or footer from the Header & Footer list now publishes the latest builder changes.

= 1.0.6 =
* Fix: Opening a page in the builder no longer changes the live page.
* Fix: Autosaves are stored as a draft; visitors see changes only after Publish. Preview shows the draft.
* Fix: Shortcode output such as forms is no longer stripped on pages, headers and footers.
* Security: Free-form shortcodes and page structure changes (including nested components) are enforced server-side by capability.
* Security: Builder document endpoints only accept supported post types; image paths can no longer resolve outside the uploads/content folders.

= 1.0.5 =
* New: Metric → Header & Footer. Build multiple headers and footers in the Metric builder and choose where each appears with Elementor-style display conditions. Includes new Site Header and Site Footer components. Replaces the removed file editor.
* Security: Removed the Header & Footer file editor; the plugin no longer writes to theme or plugin folders.
* Security: The builder screen now checks edit permission for the page and requires a nonce before converting a page to Metric.
* Security: Publishing now requires the page type's own publish capability.
* Compiled cache and optimized images are stored in uploads/metricpage-builder/.
* Admin CSS and JavaScript are loaded as enqueued files instead of inline tags.
* Removed Google Fonts from the editor canvas; the canvas uses your theme's fonts.
* Removed site-specific defaults from Settings.
* Added uninstall cleanup for plugin settings, capabilities and cache files.
* New: Use Metric on Posts as well as Pages (filterable with `metric_supported_post_types`).
* New: WordPress's post-locking now protects the builder, so two people can no longer silently overwrite each other's edits to the same page or header/footer.
* New: Undo/redo in the builder (Ctrl/Cmd+Z, Ctrl/Cmd+Shift+Z).
* New: Container component — group components into a responsive grid (columns can differ on desktop/tablet/mobile), with drag-and-drop nesting in the Page Structure sidebar and on the canvas, and a full Style tab (background color/image/gradient, padding, margin, border, shadow, alignment).
* Fix: the editor canvas now shows every built-in component's real styling while you edit (it previously loaded only the active theme's CSS, not the plugin's own).
* Fix: `<style>` blocks shipped by theme-kit components were being stripped down to their bare CSS text and printed visibly on the page; also fixes any `--custom-property` inside them being corrupted into `&#8211;` characters.
* The Container's settings are now grouped into collapsible, Elementor-style sections (Layout, Background, Text, Border & shadow) plus a dedicated Advanced tab for spacing — instead of one long flat list.

= 1.0.4 =
* Universal Plugin Components: Bundled 5 built-in core starter components (metric_hero, metric_text, metric_cards, metric_cta, metric_faq) and core-components.css so MetricPage Builder is 100% ready to use out-of-the-box on any WordPress theme.

= 1.0.3 =
* Dynamic Drop Indicators: Real-time top/bottom position calculation during section dragging with blue indicator lines and centered badges on live iframe canvas and sidebar list.
* Section Card Redesign: Overhauled structure sidebar section cards with modern white cards, subtle borders, elevated shadows, section type SVG icon badges, left-accent border indicators for active items, 6-dot drag handles, and interactive red trash icons.
* Component Search UI: Upgraded component search input with inner SVG search icon, focus ring outline, and smooth background transitions.
* Drag & Drop Reordering: Removed legacy up/down arrow buttons in favor of drag-and-drop section reordering and in-between drop insertion.
* Import & Export UI: Reduced visual noise of Export and Import buttons in toolbar header using a subtle ghost button style.

= 1.0.2 =
* Default Sections Tab: Editor opens with the Sections (Structure) tab active by default.
* Page Import / Export: Full page schema JSON export and import capabilities in editor toolbar.
* WordPress 7.1 Compatibility: Updated tested compatibility header to 7.1.
* Plugin Check Compliance: Fixed PHPCS variable prefixing, input sanitization, and view template variable warnings.
* Build Package Isolation: Moved all production ZIP build artifacts to /wp-content/builds/.

= 1.0.1 =
* Global Settings Integration: Added global typography controls (H1-H6, paragraph, blockquote font sizes & line heights), brand color tokens, and border radius settings.
* Compile Cache Clearance: Automatic compile cache flushing upon saving settings in WP Admin.
* Admin Bar Action: Global "Clear Metric Cache" action button in WordPress admin bar.
* Font Unit Presets: Quick font size unit preset toggles (px, rem, fluid) and auto-sanitization.

= 1.0.0 =
* Initial release of MetricPage Builder featuring schema-driven data model, SSR compile pipeline, thin editor library, and regenerable SSR compile cache.
