# Advance Post Grid — Roadmap

Current version: **1.1.5**

---

## v1.1.6 — Bug Fixes

### Critical

- **Broken block wrapper attributes** (`src/render.php` line 38)
  `get_block_wrapper_attributes()` is passed through `esc_html()`, which HTML-encodes all quote characters in the returned attribute string (e.g. `class="..."` becomes `class=&quot;...&quot;`). This breaks every block-level class and style injected by WordPress, including alignment. Fix: output the return value directly — `echo get_block_wrapper_attributes()`.

- **Invalid HTML when "Post Link" is disabled** (`src/render.php` lines 62, 70, 97)
  When `showHideLink` is `false`, the template outputs `<div href="...">` for both the image wrapper and the heading wrapper. `href` is not a valid attribute on a `<div>`. Fix: omit the `href` attribute entirely when the element is a `<div>`.

### Pagination

- **Pagination broken with plain permalinks** (`advance-post-grid.php` line 282)
  `get_page_number_from_url()` uses the regex `/\/page\/(\d+)\//`, which only matches WordPress pretty permalink URLs (`/page/2/`). With plain permalink structures (`?paged=2`) it always returns `null`, rendering the first page regardless of which page was requested. Fix: fall back to `get_query_var('paged')` or parse the `paged` query parameter.

- **`paged` defaults to `null` instead of `1`** (`src/render.php` line 44)
  When `get_page_number_from_url()` returns `null` (e.g. on page 1 or with plain permalinks), `WP_Query` receives `'paged' => null`. Fix: default to `1` — `$wo_apg_url_page_number ?? 1`.

- **Dead code in `pagination()` function** (`advance-post-grid.php` lines 84–88)
  The `if ( true === $is_ajax )` branch and its `else` branch both assign the same value (`$ajax_paged`) to `$paged`. The condition has no effect. Additionally, the ajax pagination branch generates `data-value` buttons with no corresponding JavaScript handler in `view.js`, so clicking them does nothing.

### Editor

- **Raw `fetch()` instead of `apiFetch`** (`src/edit.jsx` line 17)
  Post types are fetched using a hardcoded relative path (`/wp-json/wp/v2/types`) without a WordPress nonce. This fails in subdirectory WordPress installations and bypasses authentication. Fix: use `@wordpress/api-fetch` which handles nonce and base URL automatically.

- **`postPerPage` attribute typed as `"string"`** (`src/block.json` line 39)
  The attribute type is `"string"` but it is used as a number in `WP_Query` (`posts_per_page`). The `NumberControl` in the editor and the PHP query treat it differently. Fix: change the type to `"integer"`.

### Assets

- **Scaffolding `console.log` in production** (`src/view.js` line 24)
  The file still contains the Create Block scaffold message: `console.log('Hello World! (from create-block-perfect-post-grid block)')`. This logs to every visitor's console on any page containing the block.

---

## v1.2.0 — Improvements

- **Remove external theme CSS variable dependency**
  `style.scss` uses `var(--cr_color_primary)` for pagination text color. This variable is defined by a specific theme and will render as an invisible color on any other theme. Replace with a hardcoded fallback or a block-scoped CSS variable with a sensible default.

- **Unlock custom post types in the editor**
  The post type selector in `edit.jsx` is filtered to a hardcoded allowlist (`post`, `page`, `product`). Users with other public post types cannot use the block. Replace the hardlist with a filter on `public: true` and `show_in_rest: true` from the REST response.

- **Expand `orderby` options**
  The Order By control only offers `title` and `date`. Add at minimum: `modified`, `menu_order`, `rand`, `comment_count` — all supported natively by `WP_Query`.

- **Add taxonomy/category filtering**
  There is no way to scope the grid to a specific category, tag, or custom taxonomy term. Add a term selector control under Post Settings.

- **Image fallback when no featured image**
  When a post has no featured image, the image wrapper is completely absent, causing inconsistent card heights. Add a configurable placeholder or a CSS-only aspect-ratio spacer.

- **Optimise `useSelect` dependency array** (`src/edit.jsx` line 41)
  The `useSelect` that fetches posts lists all block attributes as dependencies, including layout-only ones (`postGrid`, `postGridMobile`, `postGridTablet`, `enablePostGridRes`). Changing column count triggers an unnecessary re-fetch. Narrow the dependency array to only the attributes that affect the query.

- **Implement AJAX pagination**
  The `pagination()` function has an `$is_ajax` branch that renders `data-value` span buttons, but `view.js` contains no handler for them. Either complete the AJAX implementation or remove the dead branch and always use standard link-based pagination.

---

## v1.3.0 — New Features

- **Per-block color controls**
  Expose InspectorControls color pickers for button color, category badge color, and pagination active color, replacing the hardcoded `#000`/`#228476` values.

- **Card layout variants**
  Add a layout selector (horizontal card, minimal list, overlay image) as an alternative to the current single vertical card design.

- **Exclude specific posts**
  Add a post multi-select control to exclude individual posts from the query.

- **Sticky posts toggle**
  Add a toggle to include or ignore sticky posts (WordPress's `ignore_sticky_posts` query arg is currently not set, so sticky posts are always boosted to the top).
