GravityMigrate hooks

Filters

gk/gravitymigrate/export/batch-size

Filters the number of records processed for export at a time. Lower this number if you are running into performance issues.

Parameter Type Description
int $batch_size The number of items processed for export at a time. Default 10000 .

Example usage:

/**
 * Change the batch size to 100.
 *
 * @param int $batch_size The batch size of the export. Default 10000.
 *
 * @return int
 */
add_filter( 'gk/gravitymigrate/export/batch-size', function( $batch_size ) {
	return 100;
} );

gk/gravitymigrate/export/data_chunk_sizes

Filters the chunk sizes for each data type.

Parameter Type Description
array $chunk_sizes The chunk sizes for each data type.

Example usage:

/**
 * Reduce the chunk size for entries and nested entries to 100, to reduce memory usage.
 *
 * @param array $chunk_sizes The chunk sizes for each data type.
 *
 * @return array
 */
add_filter( 'gk/gravitymigrate/export/data_chunk_sizes', function( $chunk_sizes ) {
	$chunk_sizes['entries'] = 100;
	$chunk_sizes['nested_entries'] = 100;

	return $chunk_sizes;	
} );

gk/gravitymigrate/cron/clear-import-interval

Filters the amount of time to wait before removing imported files from the server.

Parameter Type Description
int $import_interval The number of seconds to wait after an import before deleting uploaded files. Default 1 hour (in seconds).

Example usage:

/**
 * Change the import interval to 1 hour.
 *
 * @param int $import_interval The number of seconds to wait after an import before deleting uploaded files. Default 1 hour (in seconds).
 *
 * @return int
 */
add_filter( 'gk/gravitymigrate/cron/clear-import-interval', function( $import_interval ) {
	return DAY_IN_SECONDS; // Wait 1 day before deleting imported files.
} );

gk/gravitymigrate/cron/clear-export-interval

Filters the amount of time to wait before removing exported files from the server.

Parameter Type Description
int $import_interval The number of seconds to wait after an export before deleting generated files. Default 3 hours (in seconds).

Example usage:

/**
 * Change the export interval to 1 hour.
 *
 * @param int $export_interval The number of seconds to wait after an export before deleting generated files.
 *
 * @return int
 */
add_filter( 'gk/gravitymigrate/cron/clear-export-interval', function( $export_interval ) {
	return 3600; // 1 hour
} );

Actions

gk/gravitymigrate/upload/after-upload

Runs after a file is uploaded.

Parameter Type Description
string $new_file_path The path to the uploaded file.
string password The password for the uploaded file.

Example usage:

/**
 * Do something after a file is uploaded.
 *
 * @param string $new_file_path The path to the uploaded file.
 * @param string $password      The password for the uploaded file.
 */
add_action( 'gk/gravitymigrate/upload/after-upload', function( $new_file_path, $password ) {
	// Your code here.
}, 10, 2 );
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us