GravityKit\GravityMigrate\Import
Gravity Forms import class.
Source: src/Import.php:21
Details
- Kind:
class - Namespace:
GravityKit\GravityMigrate
Properties
| Property | Type | Description |
|---|---|---|
$chunk_size | int | Stores the chunk size used for imports |
$data_chunk_sizes | array | Chunks sizes for migrating data types. |
$temp_prefix | string | Temp prefix for imported tables. |
$import_info | array | Import information from JSON file. |
Methods
| Method | Description |
|---|---|
__construct() | Constructor. |
get_instance() | Returns class instance. |
get_file_object() | Returns the SplFileObject for the provided file. |
get_num_chunks_in_file() | Returns the number of chunks in an SQL file. |
import_chunk() | Imports a chunk of a provided SQL file into the database |
get_uploads_data() | Creates a query to get upload meta fields attached to gravity form entries. |
import_lock_check() | Checks if import lock is required. |
submissions_block_check() | Check if Gravity Forms is currently upgrading the database. |
ajax_routes() | Imports the data. |
cancel_import() | Cancels the crashed import request. |
delete_all_temp_tables() | Deletes all migration temporary tables. |
remove_ansi_quotes() | Removes ANSI quotes from a given string and replaces them with backticks. |
convert_to_temp_query() | Converts a query to run on temporary tables. |
str_replace_first() | Replaces first instance of a string. |
process_import_file() | Processes the imported file. |
update_gravity_forms_gutenberg_blocks() | Updates the form ID in Gravity Forms Gutenberg blocks, including innerBlocks. |
update_inner_blocks() | Recursively updates form IDs within innerBlocks. |
update_gravity_forms_classic_shortcodes() | Updates the form ID in Gravity Forms classic shortcodes. |
get_attr_name() | Returns the attribute name. |
update_gravity_forms_ids_in_content() | Updates the form IDs in Post content (Gutenberg blocks and classic shortcodes). |
update_gravity_ids_in_array() | Updates the form IDs in Array (Gutenberg blocks and classic shortcodes). |
update_gravity_post_ids_in_metas() | Updates the form IDs in Post metas (Gutenberg blocks and classic shortcodes). |
Method Reference
__construct()
public function __construct()
Constructor.
Since: 1.0.0
Source: src/Import.php:122
get_instance()
public static function get_instance(): Import
Returns class instance.
Returns
Import
Since: 1.0.0
Source: src/Import.php:151
get_file_object()
public function get_file_object( $file, $line=0 )
Returns the SplFileObject for the provided file.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$file | string | Dump file. | |
$line | int | 0 | Line number. |
Returns
SplFileObject| WP_Error
Since: 1.0.0
Source: src/Import.php:224
get_num_chunks_in_file()
public function get_num_chunks_in_file( $file )
Returns the number of chunks in an SQL file.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$file | SplFileObject | SPL File. |
Returns
int|object| WP_Error
Since: 1.0.0
Source: src/Import.php:249
import_chunk()
public function import_chunk( $file, $info_file_path, $chunk=0, $current_query='' )
Imports a chunk of a provided SQL file into the database
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$file | string | SQL File. | |
$info_file_path | string | Path of the info file. | |
$chunk | int | 0 | Chunk of the SQL file. |
$current_query | string | '' | Remaining query. |
Returns
array|object| WP_Error
Since: 1.0.0
Source: src/Import.php:276
get_uploads_data()
public function get_uploads_data( $table, $where, $uploads_data=[] )
Creates a query to get upload meta fields attached to gravity form entries.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$table | string | Uploads meta table name. | |
$where | array | Array of where statements for all tables. | |
$uploads_data | array | [] | Initiation variable. |
Returns
string
Since: 1.0.0
Source: src/Import.php:492
import_lock_check()
public function import_lock_check( $chunk )
Checks if import lock is required.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$chunk | string |
Returns
void
Throws
Exception
Since: 1.0.0
Source: src/Import.php:614
submissions_block_check()
public function submissions_block_check()
Check if Gravity Forms is currently upgrading the database.
Returns
void
Throws
Exception
Since: 1.0.0
Source: src/Import.php:651
ajax_routes()
public function ajax_routes( $routes )
Imports the data.
First, it will import the dump file in chunks. Then it will setup the data for insertion into real tables.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$routes | array | Setting up routes for Foundation. |
Returns
array
Since: 1.0.0
Source: src/Import.php:671
cancel_import()
public function cancel_import()
Cancels the crashed import request.
Returns
void
Source: src/Import.php:2647
delete_all_temp_tables()
public function delete_all_temp_tables()
Deletes all migration temporary tables.
Returns
void
Since: 1.0.0
Source: src/Import.php:2711
remove_ansi_quotes()
public function remove_ansi_quotes( $string )
Removes ANSI quotes from a given string and replaces them with backticks.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$string | string | String to remove ANSI quotes from. |
Returns
string
Since: 1.0.0
Source: src/Import.php:2737
convert_to_temp_query()
public function convert_to_temp_query( $query, $export_db_prefix )
Converts a query to run on temporary tables.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$query | string | SQL query. | |
$export_db_prefix |
Returns
string
Since: 1.0.0
Source: src/Import.php:2754
str_replace_first()
public static function str_replace_first( $search, $replace, $string )
Replaces first instance of a string.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$search | string | ||
$replace | string | ||
$string | string |
Returns
string— replaced string.
Since: 1.0.0
Source: src/Import.php:2793
process_import_file()
public function process_import_file( $file_path, $password )
Processes the imported file.
Extract the zip file and return the info.json file.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$file_path | string | ZIP File path. | |
$password | string | Optional password. |
Returns
bool|mixed|void
Since: 1.0.0
Source: src/Import.php:2814
update_gravity_forms_gutenberg_blocks()
public function update_gravity_forms_gutenberg_blocks( $content, $old_id, $new_id, $id_type )
Updates the form ID in Gravity Forms Gutenberg blocks, including innerBlocks.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$content | string | Post content to search for form IDs. | |
$old_id | string | The old form ID to replace. | |
$new_id | string | The new form ID to set. | |
$id_type |
Returns
string
Since: 1.0.0
Source: src/Import.php:2863
update_inner_blocks()
public function update_inner_blocks( &$blocks, $old_id, $new_id, $id_type )
Recursively updates form IDs within innerBlocks.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
&$blocks | array | An array of Gutenberg blocks. | |
$old_id | string | The old form ID to replace. | |
$new_id | string | The new form ID to set. | |
$id_type |
Since: 1.0.0
Source: src/Import.php:2885
update_gravity_forms_classic_shortcodes()
public function update_gravity_forms_classic_shortcodes( $content, $old_id, $new_id, $id_type )
Updates the form ID in Gravity Forms classic shortcodes.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$content | string | Post content to search for form IDs. | |
$old_id | string | The old form ID to replace. | |
$new_id | string | The new form ID to set. | |
$id_type |
Returns
string
Since: 1.0.0
Source: src/Import.php:2917
get_attr_name()
public function get_attr_name( $id_type, $to_sync )
Returns the attribute name.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$id_type | string | ID type. | |
$to_sync | array | Attributes to sync. |
Returns
string
Since: 1.0.0
Source: src/Import.php:2963
update_gravity_forms_ids_in_content()
public function update_gravity_forms_ids_in_content( $content, $old_id, $new_id, $id_type )
Updates the form IDs in Post content (Gutenberg blocks and classic shortcodes).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$content | string | Post content to search for form IDs. | |
$old_id | string | The old form ID to replace. | |
$new_id | string | The new form ID to set. | |
$id_type |
Returns
string
Since: 1.0.0
Source: src/Import.php:2992
update_gravity_ids_in_array()
public function update_gravity_ids_in_array( $array, $old_id, $new_id, $id_type )
Updates the form IDs in Array (Gutenberg blocks and classic shortcodes).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$array | array | string | Array to search for IDs. | |
$old_id | string | The old ID to replace. | |
$new_id | string | The new ID to set. | |
$id_type |
Returns
array|string
Since: 1.0.0
Source: src/Import.php:3013
update_gravity_post_ids_in_metas()
public function update_gravity_post_ids_in_metas( $updated_post_ids )
Updates the form IDs in Post metas (Gutenberg blocks and classic shortcodes).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$updated_post_ids | string | Updated post ids against old ids. |
Returns
bool|void
Since: 1.0.0
Source: src/Import.php:3037