Skip to content

Commit

Permalink
Register blocks to make translations available in the editor (#7643)
Browse files Browse the repository at this point in the history
  • Loading branch information
merkushin authored Jul 30, 2024
1 parent a03be8b commit 8d78f98
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 3 deletions.
22 changes: 20 additions & 2 deletions includes/blocks/class-sensei-block-quiz-question.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,39 @@ public function __construct() {
Sensei_Blocks::register_sensei_block(
'sensei-lms/quiz-question',
[
'render_callback' => [ $this, 'render_quiz_question' ],
'render_callback' => '__return_empty_string',
],
Sensei()->assets->src_path( 'blocks/quiz/question-block' )
);
Sensei_Blocks::register_sensei_block(
'sensei-lms/question-description',
[
'render_callback' => '__return_empty_string',
],
Sensei()->assets->src_path( 'blocks/quiz/question-description-block' )
);
Sensei_Blocks::register_sensei_block(
'sensei-lms/question-answers',
[
'render_callback' => '__return_empty_string',
],
Sensei()->assets->src_path( 'blocks/quiz/question-answers-block' )
);
}

/**
* Renders the block as an empty string.
*
* @deprecated $$next-version$$
*
* @param array $attributes The block attributes.
* @param string $content The block content.
*
* @return string The block HTML.
*/
public function render_quiz_question( array $attributes, string $content ) : string {
public function render_quiz_question( array $attributes, string $content ): string { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
_deprecated_function( __METHOD__, '$$next-version$$', '__return_empty_string' );

return '';
}
}
2 changes: 1 addition & 1 deletion includes/blocks/class-sensei-block-quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct() {
[
'render_callback' => [ $this, 'render_quiz' ],
],
Sensei()->assets->src_path( 'blocks/quiz' )
Sensei()->assets->src_path( 'blocks/quiz/quiz-block' )
);
}

Expand Down
26 changes: 26 additions & 0 deletions includes/blocks/class-sensei-course-actions-block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* File containing the class Sensei_Course_Actions_Block.
*
* @package sensei
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Class Sensei_Course_Actions_Block
*/
class Sensei_Course_Actions_Block {
/**
* Sensei_Course_Actions_Block constructor.
*/
public function __construct() {
Sensei_Blocks::register_sensei_block(
'sensei-lms/course-actions',
array(),
Sensei()->assets->src_path( 'blocks/course-actions-block/course-actions' )
);
}
}
1 change: 1 addition & 0 deletions includes/blocks/class-sensei-global-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public function initialize_blocks() {
new Sensei_Course_Progress_Block();
new Sensei_Course_Overview_Block();
new Sensei_Course_List_Block();
new Sensei_Course_Actions_Block();
}

/**
Expand Down

0 comments on commit 8d78f98

Please sign in to comment.