Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/config
/node_modules
/tests
/bin

.distignore
.editorconfig
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/node_modules export-ignore -diff
/tests export-ignore
/vendor export-ignore -diff

/bin export-ignore
/.distignore export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
Expand Down
2 changes: 1 addition & 1 deletion .plugin-data
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.1.0",
"version": "2.1.1",
"slug": "blockparty-faq"
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.1.1] - 2026-08-04

### Changed

- Performance improvements removed script blocking time.

## [2.1.0] - 2026-06-30

### Added
Expand Down
39 changes: 4 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,47 +44,16 @@ A Gutenberg block for SEO friendly FAQ in an accessible accordion.
- `npm run start` - Start the development server with hot reload
- `npm run env:start` - Start the WordPress environment (wp-env)
- `npm run env:stop` - Stop the WordPress environment
- `npm run bump -- <patch|minor|major|x.y.z>` - Bump the plugin version across package, blocks, PHP, and docs

### Note

FAQ structured data (JSON-LD) requires Yoast SEO, Rank Math, or SEOPress. All three plugins are available in the local wp-env environment; keep only one active in the WordPress admin when testing a specific integration. SEO plugin files are not versioned in the repository (installed via Composer into `.wp-env/plugins/`).

## Changelog

### 1.0.0 - 2024-04-02
See [readme.txt](readme.txt) and [CHANGELOG.md](CHANGELOG.md) for the full version history.

- initial commit.
---

### 1.0.1 - 2024-04-03

- fix css variable names

### 1.0.2 - 2024-06-06

- Add support for PHP 8.2

### 2.0.0 - 2026-01-26

- **Major block structure refactoring** : Transition from a monolithic block to a nested architecture with child blocks (`faq-item`, `faq-question`, `faq-answer`)
- **Configurable accordion mode** : Added `isAccordion` attribute allowing to toggle between an interactive accordion mode and a static mode
- **InnerBlocks support in answers** : Ability to add any Gutenberg block (lists, paragraphs, images, etc.) in FAQ answers
- **Front-end JavaScript** : Added `script.js` to handle accordion interactivity on the front-end with customizable configuration via the `beapi_faq_block_config` filter
- **Automatic migration** : Migration system from the old format (`questions` array attribute) to the new format (InnerBlocks)
- **Complete internationalization** : Support for PO/MO translations for PHP and JSON for JavaScript
- **Aligned build structure** : Reorganization to follow the `blockparty-accordion` model with `block.json` in each block directory
- **Add/remove buttons** : Added buttons to add and remove FAQ items directly from the editor

### 2.0.1 - 2026-01-27

- Fix build blocks

### 2.0.2 - 2026-01-27

- Add missing isAccordion attribute

### 2.0.3 - 2026-02-17

- Allow adding "Button" blocks in the answer content
- Add spacing support for answers
- Add font size support for the question
- Strip HTML tags from the question in structured data
Developed with ❤️ by [Be API](https://beapi.fr)
262 changes: 262 additions & 0 deletions bin/bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
#!/usr/bin/env bash
#
# Bump the plugin version across package, block metadata, PHP, and docs.
#
# Usage (no chmod required):
# bash bin/bump.sh patch
# bash bin/bump.sh minor
# bash bin/bump.sh major
# bash bin/bump.sh 2.2.0
# npm run bump -- patch
# npm run bump -- 2.2.0
#
# macOS sed (-i '') is assumed.
#

set -euo pipefail

# ---------------------------------------------------------------------------
# Assets — add or remove paths here
# ---------------------------------------------------------------------------

ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"

# JSON files that expose a top-level "version" field
JSON_VERSION_FILES=(
".plugin-data"
"package.json"
"src/faq/block.json"
"src/faq-answer/block.json"
"src/faq-item/block.json"
"src/faq-question/block.json"
)

PACKAGE_LOCK_FILE="package-lock.json"
PHP_FILE="blockparty-faq.php"
README_TXT="readme.txt"
CHANGELOG="CHANGELOG.md"

# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------

UPDATED_FILES=()

log_updated() {
UPDATED_FILES+=( "$1" )
}

require_file() {
local file="$1"
if [[ ! -f "${ROOT_DIR}/${file}" ]]; then
echo "Error: Missing file ${file}" >&2
exit 1
fi
}

replace_json_version() {
local file="$1"
local path="${ROOT_DIR}/${file}"
require_file "${file}"
sed -i '' "s/\"version\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"version\": \"${VERSION}\"/" "${path}"
log_updated "${file}"
}

usage() {
local code="${1:-0}"
echo "Usage: bash bin/bump.sh <patch|minor|major|x.y.z>"
echo ""
echo "Examples:"
echo " bash bin/bump.sh patch"
echo " bash bin/bump.sh minor"
echo " bash bin/bump.sh 2.2.0"
echo " npm run bump -- patch"
exit "${code}"
}

resolve_version() {
local current="$1"
local input="$2"

if [[ "${input}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "${input}"
return
fi

local major minor patch
IFS='.' read -r major minor patch <<< "${current}"

case "${input}" in
major)
echo "$((major + 1)).0.0"
;;
minor)
echo "${major}.$((minor + 1)).0"
;;
patch)
echo "${major}.${minor}.$((patch + 1))"
;;
*)
echo "Error: Unknown bump argument \"${input}\". Use patch, minor, major, or an explicit x.y.z version." >&2
exit 1
;;
esac
}

escape_sed() {
printf '%s\n' "$1" | sed -e 's/[.[\*^$\/]/\\&/g'
}

# ---------------------------------------------------------------------------
# Args
# ---------------------------------------------------------------------------

if [[ -z "${1:-}" || "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage "$([[ -n "${1:-}" ]] && echo 0 || echo 1)"
fi

INPUT="$1"

require_file ".plugin-data"
CURRENT="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([0-9]*\.[0-9]*\.[0-9]*\)".*/\1/p' "${ROOT_DIR}/.plugin-data" | head -n 1)"

if [[ -z "${CURRENT}" ]]; then
echo "Error: Could not read current version from .plugin-data" >&2
exit 1
fi

if ! [[ "${CURRENT}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid current version \"${CURRENT}\" in .plugin-data" >&2
exit 1
fi

VERSION="$(resolve_version "${CURRENT}" "${INPUT}")"

if [[ "${VERSION}" == "${CURRENT}" ]]; then
echo "Error: Version is already ${CURRENT}" >&2
exit 1
fi

echo "Bumping version: ${CURRENT} → ${VERSION}"
TODAY="$(date +%Y-%m-%d)"

# ---------------------------------------------------------------------------
# JSON version fields
# ---------------------------------------------------------------------------

for file in "${JSON_VERSION_FILES[@]}"; do
replace_json_version "${file}"
done

# ---------------------------------------------------------------------------
# package-lock.json (root + packages[""] only)
# ---------------------------------------------------------------------------

if [[ -f "${ROOT_DIR}/${PACKAGE_LOCK_FILE}" ]]; then
# Root "version" (near top of file)
sed -i '' '1,5s/"version": "[0-9]*\.[0-9]*\.[0-9]*"/"version": "'"${VERSION}"'"/' "${ROOT_DIR}/${PACKAGE_LOCK_FILE}"
# packages[""].version
sed -i '' '6,12s/"version": "[0-9]*\.[0-9]*\.[0-9]*"/"version": "'"${VERSION}"'"/' "${ROOT_DIR}/${PACKAGE_LOCK_FILE}"
log_updated "${PACKAGE_LOCK_FILE}"
fi

# ---------------------------------------------------------------------------
# Main plugin PHP
# ---------------------------------------------------------------------------

require_file "${PHP_FILE}"
sed -i '' "s/^\( \* Version:[[:space:]]*\)$(escape_sed "${CURRENT}")/\1${VERSION}/" "${ROOT_DIR}/${PHP_FILE}"
sed -i '' "s/define( 'BLOCKPARTY_FAQ_VERSION', '$(escape_sed "${CURRENT}")' )/define( 'BLOCKPARTY_FAQ_VERSION', '${VERSION}' )/" "${ROOT_DIR}/${PHP_FILE}"
log_updated "${PHP_FILE}"

# ---------------------------------------------------------------------------
# readme.txt — Stable tag + changelog + Upgrade Notice stubs
# ---------------------------------------------------------------------------

require_file "${README_TXT}"
sed -i '' "s/^\(Stable tag:[[:space:]]*\)$(escape_sed "${CURRENT}")/\1${VERSION}/" "${ROOT_DIR}/${README_TXT}"

if grep -q "^= ${VERSION} - " "${ROOT_DIR}/${README_TXT}"; then
echo "Error: readme.txt already contains a changelog entry for ${VERSION}" >&2
exit 1
fi

awk -v ver="${VERSION}" -v today="${TODAY}" -v current="${CURRENT}" '
{
if ( $0 ~ ("^= " current " - ") ) {
print "= " ver " - " today " ="
print "* TBD"
print ""
}
print
}
' "${ROOT_DIR}/${README_TXT}" > "${ROOT_DIR}/${README_TXT}.tmp"
mv "${ROOT_DIR}/${README_TXT}.tmp" "${ROOT_DIR}/${README_TXT}"

if grep -q "^= ${VERSION} =$" "${ROOT_DIR}/${README_TXT}"; then
echo "Error: readme.txt already contains an Upgrade Notice for ${VERSION}" >&2
exit 1
fi

awk -v ver="${VERSION}" '
{
print
if ( $0 == "== Upgrade Notice ==" ) {
getline
print ""
print "= " ver " ="
print "TBD"
print ""
if ( $0 != "" ) {
print
}
}
}
' "${ROOT_DIR}/${README_TXT}" > "${ROOT_DIR}/${README_TXT}.tmp"
mv "${ROOT_DIR}/${README_TXT}.tmp" "${ROOT_DIR}/${README_TXT}"
log_updated "${README_TXT}"

# ---------------------------------------------------------------------------
# CHANGELOG.md — Keep a Changelog entry
# ---------------------------------------------------------------------------

require_file "${CHANGELOG}"

if grep -q "^## \[${VERSION}\]" "${ROOT_DIR}/${CHANGELOG}"; then
echo "Error: CHANGELOG.md already contains an entry for ${VERSION}" >&2
exit 1
fi

awk -v ver="${VERSION}" -v today="${TODAY}" '
{
print
if ( !inserted && index( $0, "Semantic Versioning" ) ) {
getline
print ""
print "## [" ver "] - " today
print ""
print "### Changed"
print ""
print "- TBD"
print ""
inserted = 1
# Marker is followed by a blank line; skip the consumed blank.
next
}
}
' "${ROOT_DIR}/${CHANGELOG}" > "${ROOT_DIR}/${CHANGELOG}.tmp"
mv "${ROOT_DIR}/${CHANGELOG}.tmp" "${ROOT_DIR}/${CHANGELOG}"
log_updated "${CHANGELOG}"

# ---------------------------------------------------------------------------
# Summary
# ---------------------------------------------------------------------------

echo ""
echo "Bumped version ${CURRENT} → ${VERSION}"
echo "Updated files:"
for file in "${UPDATED_FILES[@]}"; do
echo " - ${file}"
done
echo ""
echo "Fill in the TBD changelog entries before releasing."
4 changes: 2 additions & 2 deletions blockparty-faq.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: A FAQ block for WordPress Editor that provided structured data based on FAQ schema.
* Requires at least: 6.2
* Requires PHP: 8.1
* Version: 2.1.0
* Version: 2.1.1
* Plugin URI: https://beapi.fr
* Author: Be API Technical team
* Author URI: https://beapi.fr
Expand Down Expand Up @@ -45,7 +45,7 @@
}

// Plugin constants
define( 'BLOCKPARTY_FAQ_VERSION', '2.1.0' );
define( 'BLOCKPARTY_FAQ_VERSION', '2.1.1' );

// Plugin URL and PATH
define( 'BLOCKPARTY_FAQ_DIR', plugin_dir_path( __FILE__ ) );
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading