Skip to content

Commit

Permalink
Don't create default forms anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
jrtashjian committed Jun 30, 2024
1 parent 96df049 commit 73d6355
Showing 1 changed file with 0 additions and 40 deletions.
40 changes: 0 additions & 40 deletions includes/BlockLibrary/BlockLibraryServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,53 +42,13 @@ public function register(): void {}
* @return void
*/
public function boot(): void {
add_action( 'wp_loaded', array( $this, 'activation' ) );
add_action( 'init', array( $this, 'register_blocks' ) );
add_action( 'init', array( $this, 'register_patterns' ) );

add_filter( 'block_categories_all', array( $this, 'register_categories' ) );
add_filter( 'block_type_metadata_settings', array( $this, 'update_layout_support' ), 10, 2 );
}

/**
* Create the default forms.
*/
public function activation() {
if ( ! get_transient( 'omniform_just_activated' ) ) {
return;
}

$existing_forms = get_posts(
array(
'post_status' => 'any',
'post_type' => 'omniform',
)
);

if ( ! empty( $existing_forms ) ) {
return;
}

/** @var \OmniForm\FormTypes\FormTypesManager */ // phpcs:ignore
$form_types_manager = $this->getContainer()->get( FormTypesManager::class );

foreach ( $this->get_block_patterns() as $form ) {
wp_insert_post(
array(
'post_type' => 'omniform',
'post_status' => 'draft',
'post_name' => $form['name'],
'post_title' => $form['title'],
'post_content' => $form['content'],
'tax_input' => array(
'omniform_type' => $form_types_manager->validate_form_type( $form['type'] ?? '' ),
),
'meta_input' => $form['meta'] ?? array(),
)
);
}
}

/**
* Get an array of block patterns from the BlockPatterns/ directory,.
*
Expand Down

0 comments on commit 73d6355

Please sign in to comment.