Skip to content

Commit

Permalink
Merge pull request #640 from stellarwp/feature/header-translations
Browse files Browse the repository at this point in the history
Feature/header translations
  • Loading branch information
mark-c-woodard authored Jan 6, 2025
2 parents 7aee315 + a9dcb22 commit 35d8a59
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
14 changes: 7 additions & 7 deletions includes/blocks/class-kadence-blocks-abstract-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ public function render_css( $attributes, $content, $block_instance ) {
$css_class = Kadence_Blocks_CSS::get_instance();

if ( in_array( $this->block_name, $this->supports_merged_defaults ) ) {
$attributes = $this->get_attributes_with_defaults( $unique_id, $attributes, false );
$attributes = $this->get_attributes_with_defaults( $unique_id . get_locale(), $attributes, false );
}

// If filter didn't run in header (which would have enqueued the specific css id ) then filter attributes for easier dynamic css.
$attributes = apply_filters( 'kadence_blocks_' . str_replace( '-', '_', $this->block_name ) . '_render_block_attributes', $attributes, $block_instance );

$content = $this->build_html( $attributes, $unique_id, $content, $block_instance );
$content = $this->build_html( $attributes, $unique_id, $content, $block_instance );
if ( ! $css_class->has_styles( 'kb-' . $this->block_name . $unique_style_id ) && ! is_feed() && apply_filters( 'kadence_blocks_render_inline_css', true, $this->block_name, $unique_id ) ) {
$css = $this->build_css( $attributes, $css_class, $unique_id, $unique_style_id );
if ( ! empty( $css ) && ! wp_is_block_theme() ) {
Expand Down Expand Up @@ -382,21 +382,21 @@ public function get_html_tag( $attributes, $tag_key, $default, $allowed_tags = a
/**
* Get this blocks attributes merged with defaults from the registration.
*
* @param string $unique_id The unique id.
* @param string $cache_key The cache key (usually unique id).
* @param array $attributes The block's attributes.
* @param string $block_name The name of the block.
* @return array
*/
public function get_attributes_with_defaults( $unique_id, $attributes, $cache = true ) {
if ( ! empty( $this->attributes_with_defaults[ $unique_id ] ) ) {
return $this->attributes_with_defaults[ $unique_id ];
public function get_attributes_with_defaults( $cache_key, $attributes, $cache = true ) {
if ( ! empty( $this->attributes_with_defaults[ $cache_key ] ) ) {
return $this->attributes_with_defaults[ $cache_key ];
}

$default_attributes = $this->get_block_default_attributes();
$merged_attributes = $this->merge_attributes_with_defaults( $attributes, $default_attributes );

if ( $cache ) {
$this->attributes_with_defaults[ $unique_id ] = $merged_attributes;
$this->attributes_with_defaults[ $cache_key ] = $merged_attributes;
}
return $merged_attributes;
}
Expand Down
17 changes: 17 additions & 0 deletions wpml-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,22 @@
</key>
</key>
</gutenberg-block>
<gutenberg-block type="kadence/navigation" translate="1">
<key name="id" type="post-ids" sub-type="kadence_navigation" />
</gutenberg-block>
<gutenberg-block type="kadence/navigation-link" translate="1">
<key name="label" />
<key name="description" />
<key name="title" />
</gutenberg-block>
<gutenberg-block type="kadence/header" translate="1">
<key name="id" type="post-ids" sub-type="kadence_header" />
</gutenberg-block>
</gutenberg-blocks>
<custom-types>
<custom-type translate="1">kadence_form</custom-type>
<custom-type translate="1">kadence_navigation</custom-type>
<custom-type translate="1">kadence_header</custom-type>
</custom-types>
<custom-fields>
<custom-field action="translate">_kad_form_fields</custom-field>
Expand Down Expand Up @@ -295,5 +308,9 @@
<custom-field action="translate">_kad_form_maxwidthunit</custom-field>
<custom-field action="translate">_kad_form_maxwidth</custom-field>
<custom-field action="translate">_kad_form_importid</custom-field>

<custom-field action="translate">_kad_navigation_description</custom-field>

<custom-field action="translate">_kad_header_description</custom-field>
</custom-fields>
</wpml-config>

0 comments on commit 35d8a59

Please sign in to comment.