Skip to content

Commit

Permalink
Add filter/action to handle custom fields in importers
Browse files Browse the repository at this point in the history
  • Loading branch information
joedolson committed Nov 7, 2023
1 parent fb34b80 commit 422d411
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/css/mc-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@
font-weight: 700;
}

#mc-importer {
display: flex;
align-items: center;
gap: 12px;
#mc-importer form {
padding-bottom: .5rem;
}

.n4 {
Expand Down
22 changes: 22 additions & 0 deletions src/my-calendar-migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ function my_calendar_migration() {
}
$source = ( in_array( $_POST['source'], array( 'calendar', 'tribe' ), true ) ) ? $_POST['source'] : false;
if ( $source ) {
/**
* Handle custom fields passed from the importer before doing the import.
*
* @hook mc_handle_importer_custom_fields
*
* @param {string} $source Importer source name.
*/
do_action( 'mc_handle_importer_custom_fields', $source );
my_calendar_import( $source );
}
}
Expand Down Expand Up @@ -68,6 +76,20 @@ function my_calendar_migration() {
<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'my-calendar-nonce' ); ?>"/>
<input type="hidden" name="import" value="true" />
<input type="hidden" name="source" value="<?php echo $import_source; ?>" />
<?php
/**
* Output any custom fields or data required by the importer.
*
* @hook mc_importer_custom_fields
*
* @param {string} $output HTML output to display. Default empty.
* @param {string} $import_source Name of source being displayed.
*
* @return {string}
*/
$fields = apply_filters( 'mc_importer_custom_fields', '', $import_source );
echo $fields;
?>
<input type="submit" value="<?php _e( 'Import Events', 'my-calendar' ); ?>" name="import-calendar" class="button-primary"/>
</div>
</form>
Expand Down

0 comments on commit 422d411

Please sign in to comment.