mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Blocks: Introduce WP_Block_Type and WP_Block_Type_Registry classes.
These are the foundational classes allowing blocks to be registered and used throughout WordPress. This commit also includes the `has_block()` and `has_blocks()` functions, which are required for unit testing these classes. Merges [43742] from the 5.0 branch to trunk. Props adamsilverstein, danielbachhuber, desrosj. Fixes #45097. See #45109. git-svn-id: https://develop.svn.wordpress.org/trunk@44108 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -133,6 +133,7 @@ require dirname( __FILE__ ) . '/exceptions.php';
|
||||
require dirname( __FILE__ ) . '/utils.php';
|
||||
require dirname( __FILE__ ) . '/spy-rest-server.php';
|
||||
require dirname( __FILE__ ) . '/class-wp-rest-test-search-handler.php';
|
||||
require dirname( __FILE__ ) . '/class-wp-fake-block-type.php';
|
||||
|
||||
/**
|
||||
* A child class of the PHP test runner.
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* WP_Fake_Block_Type for testing
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Blocks
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test class extending WP_Block_Type
|
||||
*
|
||||
* @since 5.0.0
|
||||
*/
|
||||
class WP_Fake_Block_Type extends WP_Block_Type {
|
||||
|
||||
/**
|
||||
* Render the fake block.
|
||||
*
|
||||
* @param array $attributes Optional. Block attributes. Default empty array.
|
||||
* @param string $content Optional. Block content. Default empty string.
|
||||
* @return string Rendered block HTML.
|
||||
*/
|
||||
public function render( $attributes = array(), $content = '' ) {
|
||||
return '<div>' . $content . '</div>';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user