Introduces block support for PHP-only block registration, enabling developers to register blocks in PHP without requiring JavaScript registration code.
When a block declares `'supports' => array( 'autoRegister' => true )` along with a render callback, it is exposed to the client-side via a JavaScript global variable and registered automatically.
Example usage:
{{{
register_block_type(
'my-plugin/example',
array(
'title' => 'My Example Block',
'attributes' => array(
'title' => array(
'type' => 'string',
'default' => 'Hello World',
),
'count' => array(
'type' => 'integer',
'default' => 5,
),
),
'render_callback' => function ( $attributes ) {
return sprintf(
'<div %1$s>%2$s: %3$d items</div>',
get_block_wrapper_attributes(),
esc_html( $attributes['title'] ),
$attributes['count']
);
},
'supports' => array(
'autoRegister' => true,
),
)
);
}}}
Props mcsf, oandregal, ramonopoly, westonruter, wildworks.
Fixes #64639.
Built from https://develop.svn.wordpress.org/trunk@61661
git-svn-id: http://core.svn.wordpress.org/trunk@60972 1a063a9b-81f0-0310-95a4-ce76da25c4cd
58 lines
1.1 KiB
PHP
58 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* WordPress Version
|
|
*
|
|
* Contains version information for the current WordPress release.
|
|
*
|
|
* @package WordPress
|
|
* @since 1.2.0
|
|
*/
|
|
|
|
/**
|
|
* The WordPress version string.
|
|
*
|
|
* Holds the current version number for WordPress core. Used to bust caches
|
|
* and to enable development mode for scripts when running from the /src directory.
|
|
*
|
|
* @global string $wp_version
|
|
*/
|
|
$wp_version = '7.0-alpha-61661';
|
|
|
|
/**
|
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
|
*
|
|
* @global int $wp_db_version
|
|
*/
|
|
$wp_db_version = 61644;
|
|
|
|
/**
|
|
* Holds the TinyMCE version.
|
|
*
|
|
* @global string $tinymce_version
|
|
*/
|
|
$tinymce_version = '49110-20250317';
|
|
|
|
/**
|
|
* Holds the minimum required PHP version.
|
|
*
|
|
* @global string $required_php_version
|
|
*/
|
|
$required_php_version = '7.4';
|
|
|
|
/**
|
|
* Holds the names of required PHP extensions.
|
|
*
|
|
* @global string[] $required_php_extensions
|
|
*/
|
|
$required_php_extensions = array(
|
|
'json',
|
|
'hash',
|
|
);
|
|
|
|
/**
|
|
* Holds the minimum required MySQL version.
|
|
*
|
|
* @global string $required_mysql_version
|
|
*/
|
|
$required_mysql_version = '5.5.5';
|