Skip to content

WesleySmits/agent-skills / .agent/skills/wordpress-fse-generator

generating-wordpress-fse-blocks

Verified

Generates WordPress Full Site Editing blocks and theme files. Use when the user asks about block.json, Gutenberg blocks, FSE themes, WordPress block development, or theme.json configuration.

FileKindSize
SKILL.mdskill md3.8 KB
examples/block-templates.mdmarkdown6.9 KB
examples/functions-php.mdmarkdown7.0 KB
examples/theme-json.mdmarkdown3.8 KB

examples/functions-php.md

View on GitHub
# Functions.php and Theme Setup

## Complete functions.php

```php
// functions.php
<?php

if (!defined('ABSPATH')) exit;

define('THEME_VERSION', '1.0.0');
define('THEME_DIR', get_template_directory());
define('THEME_URI', get_template_directory_uri());

// Block registration
require_once THEME_DIR . '/inc/blocks.php';

// Enqueue scripts and styles
function theme_name_enqueue_assets(): void {
    wp_enqueue_style(
        'theme-name-style',
        THEME_URI . '/build/style.css',
        [],
        THEME_VERSION
    );
}
add_action('wp_enqueue_scripts', 'theme_name_enqueue_assets');

// Editor assets
function theme_name_enqueue_editor_assets(): void {
    wp_enqueue_script(
        'theme-name-blocks',
        THEME_URI . '/build/blocks/index.js',
        ['wp-blocks', 'wp-element', 'wp-editor', 'wp-components', 'wp-i18n'],
        THEME_VERSION,
        true
    );
}
add_action('enqueue_block_editor_assets', 'theme_name_enqueue_editor_assets');

// Register block category
function theme_name_block_categories(array $categories): array {
    return array_merge(
        [
            [
                'slug'  => 'theme-name',
                'title' => __('Theme Name Blocks', 'theme-name'),
                'icon'  => 'star-filled',
            ],
        ],
        $categories
    );
}
add_filter('block_categories_all', 'theme_name_block_categories');

// Register block patterns
function theme_name_register_patterns(): void {
    register_block_pattern_category('theme-name', [
        'label' => __('Theme Patterns', 'theme-name'),
    ]);

    register_block_pattern('theme-name/hero', [
        'title'       => __('Hero Section', 'theme-name'),
        'description' => __('A hero section with heading and CTA.', 'theme-name'),
        'categories'  => ['theme-name'],
        'content'     => '<!-- wp:cover {"dimRatio":50} -->...<!-- /wp:cover -->',
    ]);
}
add_action('init', 'theme_name_register_patterns');
```

## Theme Support Setup

```php
// inc/theme-support.php
<?php

function theme_name_setup(): void {
    // Add default posts and comments RSS feed links
    add_theme_support('automatic-feed-links');

    // Let WordPress manage the document title
    add_theme_support('title-tag');

    // Enable support for Post Thumbnails
    add_theme_support('post-thumbnails');

    // Register navigation menus
    register_nav_menus([
        'primary'   => __('Primary Menu', 'theme-name'),
        'footer'    => __('Footer Menu', 'theme-name'),
    ]);

    // Switch default core markup to output valid HTML5
    add_theme_support('html5', [
        'search-form',
        'comment-form',
        'comment-list',
        'gallery',
        'caption',
        'style',
        'script',
    ]);

    // Add support for Block Styles
    add_theme_support('wp-block-styles');

    // Add support for responsive embedded content
    add_theme_support('responsive-embeds');

    // Add support for editor styles
    add_theme_support('editor-styles');
    add_editor_style('build/editor.css');

    // Remove core block patterns
    remove_theme_support('core-block-patterns');
}
add_action('after_setup_theme', 'theme_name_setup');
```

## Block Patterns

```php
// inc/patterns.php
<?php

function theme_name_register_block_patterns(): void {
    register_block_pattern_category('theme-name', [
        'label' => __('Theme Patterns', 'theme-name'),
    ]);

    // Hero pattern
    register_block_pattern('theme-name/hero', [
        'title'       => __('Hero Section', 'theme-name'),
        'description' => __('A full-width hero with heading and button.', 'theme-name'),
        'categories'  => ['theme-name', 'featured'],
        'keywords'    => ['hero', 'banner', 'header'],
        'content'     => '
<!-- wp:cover {"dimRatio":50,"minHeight":500} -->
<div class="wp-block-cover" style="min-height:500px">
    <span class="wp-block-cover__background has-background-dim"></span>
    <div class="wp-block-cover__inner-container">
        <!-- wp:heading {"textAlign":"center","level":1} -->
        <h1 class="has-text-align-center">Welcome to Our Site</h1>
        <!-- /wp:heading -->
        <!-- wp:paragraph {"align":"center"} -->
        <p class="has-text-align-center">Discover what we have to offer.</p>
        <!-- /wp:paragraph -->
        <!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
        <div class="wp-block-buttons">
            <!-- wp:button -->
            <div class="wp-block-button"><a class="wp-block-button__link wp-element-button">Get Started</a></div>
            <!-- /wp:button -->
        </div>
        <!-- /wp:buttons -->
    </div>
</div>
<!-- /wp:cover -->',
    ]);

    // CTA pattern
    register_block_pattern('theme-name/cta', [
        'title'       => __('Call to Action', 'theme-name'),
        'description' => __('A simple call to action section.', 'theme-name'),
        'categories'  => ['theme-name', 'call-to-action'],
        'content'     => '
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|50"}}},"backgroundColor":"primary","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-primary-background-color has-background" style="padding-top:var(--wp--preset--spacing--50);padding-bottom:var(--wp--preset--spacing--50)">
    <!-- wp:heading {"textAlign":"center","textColor":"background"} -->
    <h2 class="has-text-align-center has-background-color has-text-color">Ready to get started?</h2>
    <!-- /wp:heading -->
    <!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center"}} -->
    <div class="wp-block-buttons">
        <!-- wp:button {"backgroundColor":"background","textColor":"foreground"} -->
        <div class="wp-block-button"><a class="wp-block-button__link has-foreground-color has-background-background-color has-text-color has-background wp-element-button">Contact Us</a></div>
        <!-- /wp:button -->
    </div>
    <!-- /wp:buttons -->
</div>
<!-- /wp:group -->',
    ]);
}
add_action('init', 'theme_name_register_block_patterns');
```

## Template Parts Registration

```php
// inc/template-parts.php
<?php

function theme_name_register_template_part_areas(array $areas): array {
    $areas[] = [
        'area'        => 'sidebar',
        'area_tag'    => 'aside',
        'label'       => __('Sidebar', 'theme-name'),
        'description' => __('Sidebar template parts.', 'theme-name'),
        'icon'        => 'sidebar',
    ];

    return $areas;
}
add_filter('default_wp_template_part_areas', 'theme_name_register_template_part_areas');
```

## Build Configuration

**package.json:**

```json
{
  "name": "theme-name",
  "scripts": {
    "build": "wp-scripts build",
    "start": "wp-scripts start",
    "lint:js": "wp-scripts lint-js",
    "lint:css": "wp-scripts lint-style"
  },
  "devDependencies": {
    "@wordpress/scripts": "^27.0.0"
  }
}
```

**webpack.config.js (optional customization):**

```js
const defaultConfig = require("@wordpress/scripts/config/webpack.config");

module.exports = {
  ...defaultConfig,
  entry: {
    "blocks/index": "./src/blocks/index.ts",
  },
};
```
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall