Skip to content

Commit d52d58b

Browse files
authored
Merge pull request #13 from BeAPI/ver/2.0.0
Release 2.0.0
2 parents ae7d1b2 + 768b88b commit d52d58b

44 files changed

Lines changed: 4303 additions & 996 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.plugin-data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"version": "1.0.2",
2+
"version": "2.0.0",
33
"slug": "blockparty-faq"
44
}

.wp-env.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"plugins": [
3+
"."
4+
]
5+
}

README.md

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,77 @@
11
# Blockparty FAQ
22

3+
A Gutenberg block for SEO friendly FAQ in an accessible accordion.
4+
5+
## Development Setup
6+
7+
### Prerequisites
8+
9+
- Node.js 20.12.0 (managed by Volta)
10+
- Docker (for wp-env)
11+
12+
### Installation
13+
14+
1. Clone the repository
15+
2. Install dependencies:
16+
17+
```bash
18+
npm install
19+
```
20+
21+
3. Build the blocks:
22+
23+
```bash
24+
npm run build
25+
```
26+
27+
4. Start the WordPress environment and install Yoast SEO:
28+
29+
```bash
30+
npm run setup:env
31+
```
32+
33+
**Note:** On Windows, you may need to run the commands separately:
34+
35+
```bash
36+
npm run start:env
37+
# Wait for WordPress to be ready (about 10-15 seconds)
38+
npm run setup
39+
```
40+
41+
### Available Scripts
42+
43+
- `npm run build` - Build the blocks for production
44+
- `npm run start` - Start the development server with hot reload
45+
- `npm run start:env` - Start the WordPress environment (wp-env)
46+
- `npm run stop:env` - Stop the WordPress environment
47+
- `npm run install:yoast` - Install and activate Yoast SEO plugin (required for schema generation)
48+
- `npm run setup:env` - Start wp-env and install Yoast SEO in one command
49+
50+
### Note
51+
52+
Yoast SEO is required for the FAQ schema (JSON-LD) generation. It is installed automatically via `npm run setup:env` but is not versioned in the repository.
53+
354
## Changelog
55+
456
### 1.0.0 - 2024-04-02
5-
* initial commit.
57+
58+
- initial commit.
659

760
### 1.0.1 - 2024-04-03
8-
* fix css variable names
61+
62+
- fix css variable names
963

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

block.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

blockparty-faq.php

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22
/**
3-
* Plugin Name: Blockparty Faq
4-
* Description: A Gutenberg block for SEO friendly FAQ in an accessible accordion
3+
* Plugin Name: Blockparty FAQ
4+
* Description: A FAQ block for WordPress Editor that provided structured data based on FAQ schema.
55
* Requires at least: 6.2
66
* Requires PHP: 8.1
7-
* Version: 1.0.2
7+
* Version: 2.0.0
88
* Plugin URI: https://beapi.fr
99
* Author: Be API Technical team
1010
* Author URI: https://beapi.fr
@@ -41,7 +41,7 @@
4141
}
4242

4343
// Plugin constants
44-
define( 'BLOCKPARTY_FAQ_VERSION', '1.0.2' );
44+
define( 'BLOCKPARTY_FAQ_VERSION', '2.0.0' );
4545

4646
// Plugin URL and PATH
4747
define( 'BLOCKPARTY_FAQ_DIR', plugin_dir_path( __FILE__ ) );
@@ -50,8 +50,49 @@
5050
require_once BLOCKPARTY_FAQ_DIR . 'includes/hooks/schema.php';
5151
require_once BLOCKPARTY_FAQ_DIR . 'includes/schema/faq_schema.php';
5252

53+
/**
54+
* Initialize plugin blocks.
55+
*
56+
* @since 1.0.0
57+
*
58+
* @return void
59+
*/
5360
function blockparty_faq_init(): void {
54-
register_block_type( __DIR__ );
61+
load_plugin_textdomain( 'blockparty-faq', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
62+
63+
// Register main block (from src/faq/block.json)
64+
register_block_type( __DIR__ . '/build/faq' );
65+
66+
// Register child blocks
67+
// These blocks are also registered via JavaScript in src/index.js,
68+
// but we need to register them in PHP so WordPress knows about their block.json metadata
69+
register_block_type( __DIR__ . '/build/faq-item' );
70+
register_block_type( __DIR__ . '/build/faq-question' );
71+
register_block_type( __DIR__ . '/build/faq-answer' );
72+
73+
// Load translations for JS
74+
wp_set_script_translations( 'blockparty-faq-editor-script', 'blockparty-faq', BLOCKPARTY_FAQ_DIR . 'languages' );
75+
76+
// Pass PHP values to main script
77+
$constants = [
78+
'accordionConfig' => apply_filters(
79+
'beapi_faq_block_config',
80+
[
81+
'allowMultiple' => true,
82+
'closedDefault' => true,
83+
'forceExpand' => false,
84+
'hasAnimation' => true,
85+
'openMultiple' => false,
86+
'panelSelector' => '.faq__panel',
87+
'prefixId' => 'block-faq',
88+
'triggerSelector' => '.faq__trigger',
89+
]
90+
),
91+
];
92+
93+
wp_localize_script( 'blockparty-faq-view-script', 'beapiFaqBlock', $constants );
94+
95+
do_action( 'blockparty_faq_init' );
5596
}
5697

5798
add_action( 'init', __NAMESPACE__ . '\\blockparty_faq_init' );

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929
},
3030
"require": {
31-
"php": "^8.1 | ^8.2",
31+
"php": "^8.1 | ^8.2 | ^8.3 | ^8.4",
3232
"ext-json": "*",
3333
"composer/installers": "^1.0 || ^2.0"
3434
},

0 commit comments

Comments
 (0)