-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Minor code tweaks/optimizations (PHP) #43375
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,22 +12,18 @@ | |
* @param WP_Block_Type $block_type Block Type. | ||
*/ | ||
function gutenberg_register_border_support( $block_type ) { | ||
// Determine if any border related features are supported. | ||
$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. | ||
if ( ! $block_type->attributes ) { | ||
$block_type->attributes = array(); | ||
} | ||
|
||
if ( $has_border_support && ! array_key_exists( 'style', $block_type->attributes ) ) { | ||
if ( block_has_support( $block_type, array( '__experimentalBorder' ) ) && ! array_key_exists( 'style', $block_type->attributes ) ) { | ||
$block_type->attributes['style'] = array( | ||
'type' => 'object', | ||
); | ||
} | ||
|
||
if ( $has_border_color_support && ! array_key_exists( 'borderColor', $block_type->attributes ) ) { | ||
if ( gutenberg_has_border_feature_support( $block_type, 'color' ) && ! array_key_exists( 'borderColor', $block_type->attributes ) ) { | ||
$block_type->attributes['borderColor'] = array( | ||
'type' => 'string', | ||
); | ||
|
@@ -48,9 +44,7 @@ function gutenberg_apply_border_support( $block_type, $block_attributes ) { | |
return array(); | ||
} | ||
|
||
$sides = array( 'top', 'right', 'bottom', 'left' ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$border_block_styles = array(); | ||
|
||
$border_block_styles = array(); | ||
$has_border_color_support = gutenberg_has_border_feature_support( $block_type, 'color' ); | ||
$has_border_width_support = gutenberg_has_border_feature_support( $block_type, 'width' ); | ||
|
||
|
@@ -106,7 +100,7 @@ function gutenberg_apply_border_support( $block_type, $block_attributes ) { | |
|
||
// Generate styles for individual border sides. | ||
if ( $has_border_color_support || $has_border_width_support ) { | ||
foreach ( $sides as $side ) { | ||
foreach ( array( 'top', 'right', 'bottom', 'left' ) as $side ) { | ||
$border = _wp_array_get( $block_attributes, array( 'style', 'border', $side ), null ); | ||
$border_side_values = array( | ||
'width' => isset( $border['width'] ) && ! gutenberg_should_skip_block_supports_serialization( $block_type, '__experimentalBorder', 'width' ) ? $border['width'] : null, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,7 @@ | |
* @param WP_Block_Type $block_type Block Type. | ||
*/ | ||
function gutenberg_register_colors_support( $block_type ) { | ||
$color_support = false; | ||
if ( property_exists( $block_type, 'supports' ) ) { | ||
$color_support = _wp_array_get( $block_type->supports, array( 'color' ), false ); | ||
} | ||
$color_support = property_exists( $block_type, 'supports' ) ? _wp_array_get( $block_type->supports, array( 'color' ), false ) : false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Short and sweet |
||
$has_text_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'text' ), true ) ); | ||
$has_background_colors_support = true === $color_support || ( is_array( $color_support ) && _wp_array_get( $color_support, array( 'background' ), true ) ); | ||
$has_gradients_support = _wp_array_get( $color_support, array( 'gradients' ), false ); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are only used once, so we don't need to assign them to a var.