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
57 changes: 56 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,66 @@
# Blockparty FAQ

A Gutenberg block for SEO friendly FAQ in an accessible accordion.

## Development Setup

### Prerequisites

- Node.js 20.12.0 (managed by Volta)
- Docker (for wp-env)

### Installation

1. Clone the repository
2. Install dependencies:

```bash
npm install
```

3. Build the blocks:

```bash
npm run build
```

4. Start the WordPress environment and install Yoast SEO:

```bash
npm run setup:env
```

**Note:** On Windows, you may need to run the commands separately:

```bash
npm run start:env
# Wait for WordPress to be ready (about 10-15 seconds)
npm run setup
```

### Available Scripts

- `npm run build` - Build the blocks for production
- `npm run start` - Start the development server with hot reload
- `npm run start:env` - Start the WordPress environment (wp-env)
- `npm run stop:env` - Stop the WordPress environment
- `npm run install:yoast` - Install and activate Yoast SEO plugin (required for schema generation)
- `npm run setup:env` - Start wp-env and install Yoast SEO in one command

### Note

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.

## Changelog

### 1.0.0 - 2024-04-02

* initial commit.

### 1.0.1 - 2024-04-03

* fix css variable names

### 1.0.2 - 2024-06-06
* Add support for PHP 8.2

* Add support for PHP 8.2
22 changes: 0 additions & 22 deletions block.json

This file was deleted.

47 changes: 44 additions & 3 deletions blockparty-faq.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Blockparty Faq
* Description: A Gutenberg block for SEO friendly FAQ in an accessible accordion
* Plugin Name: Blockparty FAQ
* 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: 1.0.2
Expand Down Expand Up @@ -50,8 +50,49 @@
require_once BLOCKPARTY_FAQ_DIR . 'includes/hooks/schema.php';
require_once BLOCKPARTY_FAQ_DIR . 'includes/schema/faq_schema.php';

/**
* Initialize plugin blocks.
*
* @since 1.0.0
*
* @return void
*/
function blockparty_faq_init(): void {
register_block_type( __DIR__ );
load_plugin_textdomain( 'blockparty-faq', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );

// Register main block (from src/faq/block.json)
register_block_type( __DIR__ . '/build/faq' );

// Register child blocks
// These blocks are also registered via JavaScript in src/index.js,
// but we need to register them in PHP so WordPress knows about their block.json metadata
register_block_type( __DIR__ . '/build/faq-item' );
register_block_type( __DIR__ . '/build/faq-question' );
register_block_type( __DIR__ . '/build/faq-answer' );

// Load translations for JS
wp_set_script_translations( 'blockparty-faq-editor-script', 'blockparty-faq', BLOCKPARTY_FAQ_DIR . 'languages' );

// Pass PHP values to main script
$constants = [
'accordionConfig' => apply_filters(
'beapi_faq_block_config',
[
'allowMultiple' => true,
'closedDefault' => true,
'forceExpand' => false,
'hasAnimation' => true,
'openMultiple' => false,
'panelSelector' => '.faq__panel',
'prefixId' => 'block-faq',
'triggerSelector' => '.faq__trigger',
]
),
];

wp_localize_script( 'blockparty-faq-view-script', 'beapiFaqBlock', $constants );

do_action( 'blockparty_faq_init' );
}

add_action( 'init', __NAMESPACE__ . '\\blockparty_faq_init' );
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
},
"require": {
"php": "^8.1 | ^8.2",
"php": "^8.1 | ^8.2 | ^8.3 | ^8.4",
"ext-json": "*",
"composer/installers": "^1.0 || ^2.0"
},
Expand Down
Loading
Loading