Skip to content

Commit

Permalink
Move category registration to init hook
Browse files Browse the repository at this point in the history
  • Loading branch information
renatho committed May 30, 2022
1 parent f22a70a commit ae5d96e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions includes/admin/class-sensei-editor-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static function instance() {
*/
public function init() {
add_action( 'init', [ $this, 'register_post_metas' ] );
add_action( 'init', [ $this, 'register_block_pattern_category' ] );
add_action( 'current_screen', [ $this, 'register_block_patterns' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_admin_scripts' ] );
}
Expand Down Expand Up @@ -95,6 +96,18 @@ public function enqueue_admin_scripts( $hook_suffix ) {
}
}

/**
* Register block pattern category.
*
* @access private
*/
public function register_block_pattern_category() {
register_block_pattern_category(
self::PATTERNS_CATEGORY,
array( 'label' => __( 'Sensei LMS', 'sensei-lms' ) )
);
}

/**
* Register block patterns.
*
Expand All @@ -105,12 +118,6 @@ public function enqueue_admin_scripts( $hook_suffix ) {
public function register_block_patterns( $current_screen ) {
$post_type = $current_screen->post_type;

// Register block pattern category.
register_block_pattern_category(
self::PATTERNS_CATEGORY,
array( 'label' => __( 'Sensei LMS', 'sensei-lms' ) )
);

if ( 'course' === $post_type ) {
$this->register_course_block_patterns();
} elseif ( 'lesson' === $post_type ) {
Expand Down

0 comments on commit ae5d96e

Please sign in to comment.