diff --git a/.distignore b/.distignore index 509b66b..15fdcd0 100644 --- a/.distignore +++ b/.distignore @@ -3,6 +3,7 @@ /.wordpress-org /node_modules /src +/bin .distignore .editorconfig diff --git a/.gitattributes b/.gitattributes index 9be1ade..acf28bd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,6 +2,7 @@ /.github export-ignore /vendor/ export-ignore -diff /node_modules export-ignore +/bin export-ignore /.distignore export-ignore /.editorconfig export-ignore diff --git a/.plugin-data b/.plugin-data index ff53658..10af834 100644 --- a/.plugin-data +++ b/.plugin-data @@ -1,4 +1,4 @@ { - "version": "1.1.3", + "version": "1.1.4", "slug": "blockparty-tabs" } diff --git a/.wordpress-org/blueprints/blueprint.json b/.wordpress-org/blueprints/blueprint.json index c3b6a21..3cf27d1 100644 --- a/.wordpress-org/blueprints/blueprint.json +++ b/.wordpress-org/blueprints/blueprint.json @@ -11,7 +11,7 @@ "pluginData": { "resource": "git:directory", "url": "https://github.com/BeAPI/blockparty-tabs", - "ref": "1.1.3", + "ref": "1.1.4", "refType": "tag" }, "options": { diff --git a/CHANGELOG.md b/CHANGELOG.md index ec6f75a..4762a64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ 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). +## 1.1.4 - 2026-08-04 + +- Performance improvements removed script blocking time. + ## 1.1.3 - 2026-04-27 - Performance improvements diff --git a/README.md b/README.md index f7f0313..68de741 100644 --- a/README.md +++ b/README.md @@ -84,27 +84,36 @@ The plugin generates semantic HTML with proper ARIA attributes: ```html
- - -
-
-
- -
-
- -
+ + +
+
+
+ +
+
+ +
``` @@ -134,9 +143,11 @@ npm run lint:css For bug reports and feature requests, please use the [GitHub issues](https://github.com/BeAPI/blockparty-tabs/issues) page. -## Credits +## Changelog -Developed by [Be API Technical Team](https://beapi.fr) +See [readme.txt](readme.txt) and [CHANGELOG.md](CHANGELOG.md) for the full version history. + +Developed with ❤️ by [Be API](https://beapi.fr) ## License diff --git a/bin/bump.sh b/bin/bump.sh new file mode 100644 index 0000000..a26218d --- /dev/null +++ b/bin/bump.sh @@ -0,0 +1,260 @@ +#!/usr/bin/env bash +# +# Bump the plugin version across project metadata, blocks, 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 1.2.0 +# npm run bump -- patch +# npm run bump -- 1.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/blockparty-tabs/block.json" + "src/blockparty-tabs-nav/block.json" + "src/blockparty-tabs-nav-item/block.json" + "src/blockparty-tabs-panel-item/block.json" + "src/blockparty-tabs-panels/block.json" +) + +PACKAGE_LOCK_FILE="package-lock.json" +PHP_FILE="blockparty-tabs.php" +README_TXT="readme.txt" +CHANGELOG="CHANGELOG.md" +README_MD="README.md" +BLUEPRINT=".wordpress-org/blueprints/blueprint.json" + +# --------------------------------------------------------------------------- +# 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 " + echo "" + echo "Examples:" + echo " bash bin/bump.sh patch" + echo " bash bin/bump.sh minor" + echo " bash bin/bump.sh 1.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 +} + +# --------------------------------------------------------------------------- +# 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}" + +# --------------------------------------------------------------------------- +# 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:]]*\)[0-9]*\.[0-9]*\.[0-9]*/\1${VERSION}/" "${ROOT_DIR}/${PHP_FILE}" +sed -i '' "s/define( 'BLOCKPARTY_TABS_VERSION', '[0-9]*\.[0-9]*\.[0-9]*' )/define( 'BLOCKPARTY_TABS_VERSION', '${VERSION}' )/" "${ROOT_DIR}/${PHP_FILE}" +log_updated "${PHP_FILE}" + +# --------------------------------------------------------------------------- +# readme.txt — Stable tag + changelog section +# --------------------------------------------------------------------------- + +require_file "${README_TXT}" +sed -i '' "s/^\(Stable tag:[[:space:]]*\)[0-9]*\.[0-9]*\.[0-9]*/\1${VERSION}/" "${ROOT_DIR}/${README_TXT}" + +if ! grep -q "^= ${VERSION} =$" "${ROOT_DIR}/${README_TXT}"; then + awk -v ver="${VERSION}" ' + { + print + if ( $0 == "== Changelog ==" ) { + print "" + print "= " ver " =" + print "" + print "* " + print "" + getline + # Consume the blank line that followed "== Changelog ==". + if ( $0 != "" ) { + print + } + } + } + ' "${ROOT_DIR}/${README_TXT}" > "${ROOT_DIR}/${README_TXT}.tmp" + mv "${ROOT_DIR}/${README_TXT}.tmp" "${ROOT_DIR}/${README_TXT}" +fi +log_updated "${README_TXT}" + +# --------------------------------------------------------------------------- +# CHANGELOG.md — Keep a Changelog entry +# --------------------------------------------------------------------------- + +require_file "${CHANGELOG}" +TODAY="$(date +%Y-%m-%d)" + +if grep -q "^## ${VERSION}" "${ROOT_DIR}/${CHANGELOG}"; then + echo " skip ${CHANGELOG} (entry for ${VERSION} already exists)" +else + awk -v ver="${VERSION}" -v today="${TODAY}" ' + { + print + if ( !inserted && index( $0, "Semantic Versioning" ) ) { + getline + print "" + print "## " ver " - " today + print "" + print "- " + 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}" +fi + +# --------------------------------------------------------------------------- +# Playground blueprint tag ref +# --------------------------------------------------------------------------- + +require_file "${BLUEPRINT}" +sed -i '' "s/\"ref\": \"[0-9]*\.[0-9]*\.[0-9]*\"/\"ref\": \"${VERSION}\"/" "${ROOT_DIR}/${BLUEPRINT}" +log_updated "${BLUEPRINT}" + +# --------------------------------------------------------------------------- +# README.md — replace old version string when present +# --------------------------------------------------------------------------- + +if [[ -f "${ROOT_DIR}/${README_MD}" ]]; then + if grep -q "${CURRENT}" "${ROOT_DIR}/${README_MD}"; then + sed -i '' "s/${CURRENT}/${VERSION}/g" "${ROOT_DIR}/${README_MD}" + log_updated "${README_MD}" + else + echo " skip ${README_MD} (no version string to update)" + fi +fi + +# --------------------------------------------------------------------------- +# Summary +# --------------------------------------------------------------------------- + +echo "" +echo "Version updated to ${VERSION} in:" +for file in "${UPDATED_FILES[@]}"; do + echo " - ${file}" +done +echo "" +echo "Done. Fill in CHANGELOG.md / readme.txt notes before releasing." diff --git a/blockparty-tabs.php b/blockparty-tabs.php index a9bbbab..5e79ca0 100644 --- a/blockparty-tabs.php +++ b/blockparty-tabs.php @@ -4,7 +4,7 @@ * Description: Accessible Tabs block for WordPress gutenberg. * Requires at least: 6.2 * Requires PHP: 8.1 - * Version: 1.1.3 + * Version: 1.1.4 * Author: Be API Technical team * Author URI: https://beapi.fr * License: GPL-2.0-or-later @@ -14,7 +14,7 @@ namespace Blockparty\Tabs; -define( 'BLOCKPARTY_TABS_VERSION', '1.1.3' ); +define( 'BLOCKPARTY_TABS_VERSION', '1.1.4' ); define( 'BLOCKPARTY_TABS_URL', plugin_dir_url( __FILE__ ) ); define( 'BLOCKPARTY_TABS_DIR', plugin_dir_path( __FILE__ ) ); define( 'BLOCKPARTY_TABS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); diff --git a/package-lock.json b/package-lock.json index 9c1602c..2ef5588 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "blockparty-tabs", - "version": "1.1.1", + "version": "1.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "blockparty-tabs", - "version": "1.1.1", + "version": "1.1.4", "license": "GPL-2.0-or-later", "dependencies": { "@beapi/icons": "^1.2.5", diff --git a/package.json b/package.json index 675ba1a..ed467de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blockparty-tabs", - "version": "1.1.1", + "version": "1.1.4", "description": "Accessible tabs block for WordPress", "author": "Be API Technical team", "license": "GPL-2.0-or-later", @@ -17,7 +17,8 @@ "stop:env": "wp-env stop", "env": "wp-env", "make-pot": "wp i18n make-pot . languages/blockparty-tabs.pot --slug=blockparty-tabs --domain=blockparty-tabs --exclude=node_modules,src", - "make-json": "wp i18n make-json languages/ --no-purge" + "make-json": "wp i18n make-json languages/ --no-purge", + "bump": "bash bin/bump.sh" }, "devDependencies": { "@wordpress/block-editor": "^12.22.0", @@ -39,4 +40,4 @@ "volta": { "node": "24.15.0" } -} \ No newline at end of file +} diff --git a/readme.txt b/readme.txt index 8fb5c20..8f22a87 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: Be API Technical team Tags: block Tested up to: 6.0 -Stable tag: 1.1.2 +Stable tag: 1.1.4 License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -31,6 +31,10 @@ directory take precedence. For example, `/assets/screenshot-1.png` would win ove == Changelog == += 1.1.4 = + +* Performance improvements removed script blocking time. + = 1.1.3 = * Performance improvements diff --git a/src/blockparty-tabs-nav-item/block.json b/src/blockparty-tabs-nav-item/block.json index 40d356e..1cb3e46 100644 --- a/src/blockparty-tabs-nav-item/block.json +++ b/src/blockparty-tabs-nav-item/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "blockparty/tabs-nav-item", - "version": "1.1.3", + "version": "1.1.4", "title": "Tab", "category": "widgets", "description": "Accessible tabs block item", diff --git a/src/blockparty-tabs-nav/block.json b/src/blockparty-tabs-nav/block.json index 14a8f55..45b85e6 100644 --- a/src/blockparty-tabs-nav/block.json +++ b/src/blockparty-tabs-nav/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "blockparty/tabs-nav", - "version": "1.1.3", + "version": "1.1.4", "title": "Tabs list", "category": "widgets", "description": "Accessible tabs block item", diff --git a/src/blockparty-tabs-panel-item/block.json b/src/blockparty-tabs-panel-item/block.json index 317f215..f80e6bc 100644 --- a/src/blockparty-tabs-panel-item/block.json +++ b/src/blockparty-tabs-panel-item/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "blockparty/tabs-panel-item", - "version": "1.1.3", + "version": "1.1.4", "title": "Panel", "category": "widgets", "icon": "layout", diff --git a/src/blockparty-tabs-panels/block.json b/src/blockparty-tabs-panels/block.json index e3c943e..0189cc9 100644 --- a/src/blockparty-tabs-panels/block.json +++ b/src/blockparty-tabs-panels/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "blockparty/tabs-panels", - "version": "1.1.3", + "version": "1.1.4", "title": "Panels", "category": "widgets", "description": "Accessible tabs block item", diff --git a/src/blockparty-tabs/block.json b/src/blockparty-tabs/block.json index d4e8aa2..2a5610a 100644 --- a/src/blockparty-tabs/block.json +++ b/src/blockparty-tabs/block.json @@ -2,7 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "blockparty/tabs", - "version": "1.1.3", + "version": "1.1.4", "title": "Tabs", "category": "widgets", "description": "Accessible tabs block", diff --git a/src/blockparty-tabs/script.js b/src/blockparty-tabs/script.js index 8d02185..5e55a5a 100644 --- a/src/blockparty-tabs/script.js +++ b/src/blockparty-tabs/script.js @@ -136,11 +136,22 @@ class TabsAutomatic { } } -// Initialize tablist - -window.addEventListener( 'load', function () { +/** + * Initialize all tablist widgets on the page. + * + * @since 1.0.0 + * @return {void} + */ +function initTabs() { const tablists = document.querySelectorAll( '.wp-block-blockparty-tabs' ); for ( let i = 0; i < tablists.length; i++ ) { new TabsAutomatic( tablists[ i ] ); } -} ); +} + +// Deferred scripts run after HTML is parsed; init immediately when ready. +if ( document.readyState === 'loading' ) { + document.addEventListener( 'DOMContentLoaded', initTabs ); +} else { + initTabs(); +}