Skip to content

italloleon/usercentrics-custom-blocks

Repository files navigation

Usercentrics Custom Blocks

A WordPress plugin that provides custom Gutenberg blocks for the Usercentrics website. This plugin was created as part of a job offer challenge for the Senior WordPress Developer role.

Features

  • FAQ Component: A dynamic, reusable FAQ block with question and answer pairs, similar to the layout on the Pricing page.
    • Includes schema.org markup for SEO optimization
    • Fully accessible according to WCAG 2.1 standards
    • Mobile responsive design

Requirements

Before setting up this project, ensure you have the following installed:

Setup

1. Clone the repository

git clone https://github.com/italloleon/usercentrics-custom-blocks.git
cd usercentrics-custom-blocks

2. Install dependencies

# Install PHP dependencies
composer install

# Install JavaScript dependencies
pnpm install

3. Start the WordPress environment

wp-env start

This will set up a local WordPress environment with the plugin activated. You can access it at:

Development

Building blocks

# Development mode (with watch)
pnpm run start:blocks

# Production build
pnpm run build:blocks

Linting and code quality

# Lint JavaScript files
pnpm run lint:js

# Lint CSS/SCSS files
pnpm run lint:css

# Check PHP code style
composer phpcs

# Fix PHP code style automatically
composer phpcbf

Creating a new block

pnpm run create-block your-block-name

Testing

composer test

Creating a plugin zip file

pnpm run zip

WordPress Environment Configuration

The WordPress environment is configured in the .wp-env.json file:

  • PHP Version: 8.1
  • WordPress Debug Mode: Enabled
  • Debug Log: Enabled
  • Debug Display: Disabled

Code Quality Tools

This project uses PHP_CodeSniffer for code quality checks and automatic code formatting.

Git Hooks

The following Git hooks are configured:

  • pre-commit: Automatically runs PHP Code Beautifier and Fixer (PHPCBF), PHP Code Sniffer (PHPCS), JavaScript linter, and CSS linter before allowing a commit.

Configuration

The coding standards are defined in phpcs.xml in the project root. This project follows PSR-12 coding standards.

Accessibility and SEO

Accessibility (WCAG 2.1)

The blocks in this plugin are built with accessibility in mind:

  • Semantic HTML structure
  • Proper ARIA attributes

SEO Optimization

The FAQ block includes schema.org markup for better search engine visibility:

  • Uses FAQPage schema for FAQ content
  • Structured data is automatically generated based on the content

License

This project is licensed under the GPL-2.0+ License - see the LICENSE file for details.

Author

Itallo Leonardo - GitHub

About

Usercentrics custom blocks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published