Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin: Ensure that PHP code for blocks is correctly assigned to WP releases #40179

Merged
merged 1 commit into from
Apr 8, 2022
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
4 changes: 3 additions & 1 deletion docs/reference-guides/block-api/block-metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ Block type frontend and editor script definition. It will be enqueued both in th

### View Script

- Type: `WPDefinedAsset` ([learn more](#wpdefinedasset))
- Type: `WPDefinedAsset`|`WPDefinedAsset[]` ([learn more](#wpdefinedasset))
- Optional
- Localized: No
- Property: `viewScript`
Expand All @@ -447,6 +447,8 @@ Block type frontend and editor script definition. It will be enqueued both in th

Block type frontend script definition. It will be enqueued only when viewing the content on the front of the site.

_Note: An option to pass also an array of view scripts exists since WordPress `6.0.0`._

### Editor Style

- Type: `WPDefinedAsset`|`WPDefinedAsset[]` ([learn more](#wpdefinedasset))
Expand Down
4 changes: 2 additions & 2 deletions lib/block-supports/border.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
function gutenberg_register_border_support( $block_type ) {
// Determine if any border related features are supported.
$has_border_support = gutenberg_block_has_support( $block_type, array( '__experimentalBorder' ) );
$has_border_support = block_has_support( $block_type, array( '__experimentalBorder' ) );
$has_border_color_support = gutenberg_has_border_feature_support( $block_type, 'color' );

// Setup attributes and styles within that if needed.
Expand Down Expand Up @@ -161,7 +161,7 @@ function gutenberg_has_border_feature_support( $block_type, $feature, $default =

// Check if the specific feature has been opted into individually
// via nested flag under `__experimentalBorder`.
return gutenberg_block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default );
return block_has_support( $block_type, array( '__experimentalBorder', $feature ), $default );
}

// Register the block support.
Expand Down
2 changes: 1 addition & 1 deletion lib/block-supports/dimensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function gutenberg_register_dimensions_support( $block_type ) {
return;
}

$has_dimensions_support = gutenberg_block_has_support( $block_type, array( '__experimentalDimensions' ), false );
$has_dimensions_support = block_has_support( $block_type, array( '__experimentalDimensions' ), false );
// Future block supports such as height & width will be added here.

if ( $has_dimensions_support ) {
Expand Down
4 changes: 2 additions & 2 deletions lib/block-supports/layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @param WP_Block_Type $block_type Block Type.
*/
function gutenberg_register_layout_support( $block_type ) {
$support_layout = gutenberg_block_has_support( $block_type, array( '__experimentalLayout' ), false );
$support_layout = block_has_support( $block_type, array( '__experimentalLayout' ), false );
if ( $support_layout ) {
if ( ! $block_type->attributes ) {
$block_type->attributes = array();
Expand Down Expand Up @@ -142,7 +142,7 @@ function gutenberg_get_layout_style( $selector, $layout, $has_block_gap_support
*/
function gutenberg_render_layout_support_flag( $block_content, $block ) {
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
$support_layout = gutenberg_block_has_support( $block_type, array( '__experimentalLayout' ), false );
$support_layout = block_has_support( $block_type, array( '__experimentalLayout' ), false );

if ( ! $support_layout ) {
return $block_content;
Expand Down
6 changes: 3 additions & 3 deletions lib/block-supports/spacing.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @param WP_Block_Type $block_type Block Type.
*/
function gutenberg_register_spacing_support( $block_type ) {
$has_spacing_support = gutenberg_block_has_support( $block_type, array( 'spacing' ), false );
$has_spacing_support = block_has_support( $block_type, array( 'spacing' ), false );

// Setup attributes and styles within that if needed.
if ( ! $block_type->attributes ) {
Expand Down Expand Up @@ -44,8 +44,8 @@ function gutenberg_apply_spacing_support( $block_type, $block_attributes ) {
}

$attributes = array();
$has_padding_support = gutenberg_block_has_support( $block_type, array( 'spacing', 'padding' ), false );
$has_margin_support = gutenberg_block_has_support( $block_type, array( 'spacing', 'margin' ), false );
$has_padding_support = block_has_support( $block_type, array( 'spacing', 'padding' ), false );
$has_margin_support = block_has_support( $block_type, array( 'spacing', 'margin' ), false );
$block_styles = isset( $block_attributes['style'] ) ? $block_attributes['style'] : null;

if ( ! $block_styles ) {
Expand Down
Loading