New $ Sign Issue: Now Strips Out Content
- This topic has 2 replies, 3 voices, and was last updated 9 months ago by
Mauro.
-
AuthorPosts
-
July 18, 2024 at 1:53 AM #45924
Johannes Gross
ParticipantI know you just fixed a bug that caused the $ to be escaped. However, I now ran into an issue where $100/person in a paragraph block within the <InnerBlocks /> go changed to 0/person. After I escaped it in the paragraph block (\$100/person), it displayed it correctly.
Here is my block setup:
$meta_boxes[] = array( 'id' => 'twt-date', 'title' => 'TWT Date', 'type' => 'block', 'icon' => 'editor-table', 'category' => 'layout', //'context' => 'side', 'render_template' => get_stylesheet_directory() . '/blocks/twt-date.php', 'enqueue_assets' => function () { wp_enqueue_style( 'twt-hero', get_stylesheet_directory_uri() . '/blocks/twt-date.css', array(), filemtime( get_stylesheet_directory() . "/blocks/twt-date.css" ) ); }, 'supports' => array( 'anchor' => true, 'customClassName' => true ), 'fields' => array( array( 'name' => 'Date', 'id' => 'date', 'type' => 'date', 'timestamp' => true ), array( 'name' => 'Custom Month', 'id' => 'custom_month', 'type' => 'text', ), array( 'name' => 'Custom Day', 'id' => 'custom_day', 'type' => 'text', ), array( 'name' => 'Custom Year', 'id' => 'custom_year', 'type' => 'text', ) ) );
And here is my template:
'<?php
$attr = $attributes;
// Assign anchor if available
$id = $attr['anchor'] ?? '';// Custom CSS class name.
$class = trim('twt-date-c ' . ( $attr['className'] ?? '' ));
?>
<div<?= empty($id) ? '' : ' id="'.esc_attr($id).'"'; ?><?= empty( $class ) ? '' : ' class="'.esc_attr($class). '"'; ?>>
<?php
if(!empty($attr['data']['custom_month']) || !empty($attr['data']['custom_year']) || !empty($attr['data']['custom_day'])) {
?>
<div class="twt-date">
<div class="m<?= empty($attr['data']['custom_day']) ? ' all-month' : ''; ?>"><?= $attr['data']['custom_month'] ?? ''; ?></div>
<div class="d"><?= $attr['data']['custom_day'] ?? ''; ?></div>
<div class="y"><?= $attr['data']['custom_year'] ?? ''; ?></div>
</div>
<?php
} elseif(!empty($attr['data']['date'])) {
$date = new DateTime();
$date->setTimestamp($attr['data']['date']);
?><div class="twt-date">
<div class="m"><?= $date->format('M'); ?></div>
<div class="d"><?= $date->format('j'); ?></div>
<div class="y"><?= $date->format('Y'); ?></div>
</div>
<?php
}
?>
<div class="twt-date-content">
<InnerBlocks />
</div>
</div>
`July 19, 2024 at 10:58 PM #45949Peter
ModeratorHello Johannes,
Thank you for your feedback.
I've escalated this issue to the development team to fix it in the next update of the block plugin.
July 22, 2024 at 2:12 PM #45968Mauro
ParticipantI confirm this issue is in the latest update with all my custom MB Blocks
-
AuthorPosts
- You must be logged in to reply to this topic.