Skip to content
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
1 change: 1 addition & 0 deletions blockparty-faq.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

// Hooks
require_once BLOCKPARTY_FAQ_DIR . 'includes/Hooks/Schema_Hooks.php';
require_once BLOCKPARTY_FAQ_DIR . 'includes/Hooks/Polylang_Hooks.php';

/**
* Initialize plugin blocks.
Expand Down
23 changes: 23 additions & 0 deletions includes/Hooks/Polylang_Hooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Blockparty\Faq\Hooks;

/**
* Declare FAQ block attributes that Polylang Pro should translate.
*
* Without this, Autopoly translates the saved HTML of faq-question but leaves
* the `question` attribute in the source language, which breaks block validation.
*
* @param array $rules Parsing rules keyed by block name, then attribute name.
*
* @return array
*/
function translate_block_attributes( array $rules ): array {
$rules['blockparty/faq-question'] = [
'question' => true,
];

return $rules;
}

add_filter( 'pll_blocks_rules_for_attributes', __NAMESPACE__ . '\\translate_block_attributes' );
Loading