Skip to content
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

Register blocks to make translations available in the editor #7643

Merged
merged 4 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
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' => [ $this, '__return_empty_string' ],
merkushin marked this conversation as resolved.
Show resolved Hide resolved
merkushin marked this conversation as resolved.
Show resolved Hide resolved
],
Sensei()->assets->src_path( 'blocks/quiz/question-block' )
);
Sensei_Blocks::register_sensei_block(
'sensei-lms/question-description',
[
'render_callback' => [ $this, '__return_empty_string' ],
merkushin marked this conversation as resolved.
Show resolved Hide resolved
],
Sensei()->assets->src_path( 'blocks/quiz/question-description-block' )
);
Sensei_Blocks::register_sensei_block(
'sensei-lms/question-answers',
[
'render_callback' => [ $this, '__return_empty_string' ],
merkushin marked this conversation as resolved.
Show resolved Hide resolved
],
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
Loading